Paint App's Sketch

public class Sketch extends PApplet { int BACKGROUND = color(255); int BLACK = color(0); int strokeColor; int strokeWidth; public void settings() { fullScreen(); } public void setup() { background(BACKGROUND); strokeColor = BLACK; strokeWidth = 5; stroke(strokeColor); strokeWeight(strokeWidth); } public void draw() { drawBrushInfo(); drawColorPalette(); } public void mouseDragged() { line(mouseX, mouseY, pmouseX, pmouseY); } void drawBrushInfo() { //create background for tool info noStroke(); fill(200); rect(0, height - 24, width, 24); stroke(strokeColor); String[] components = new String[]{(int) red(strokeColor) + "", (int) green(strokeColor) + "", (int) blue(strokeColor) + ""}; String rgb = join(components, ","); //write tool info fill(strokeColor); textSize(12); text("Stroke: rgb(" + rgb + ") | Size: " + strokeWidth, 10, height - 8); } private void drawColorPalette() { PImage im = loadImage("colors.jpg"); image(im, 0, 0, width, 50); } public void mouseClicked() { loadPixels(); int currentPixelIndex = mouseY * width + mouseX; strokeColor = pixels[currentPixelIndex]; stroke(strokeColor); } }
Insert this block of code into your Sketch class and run

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.