public class ColorPicker{ int x, y, w, h, c; PImage cpImage; public ColorPicker ( int x, int y, int w, int h, int c ) { this.x = x; this.y = y; this.w = w; this.h = h; this.c = c; cpImage = new PImage( w, h ); init(); } private void init () { // draw color. int cw = w - 60; for( int i=0; i= x && mouseX < x + w && mouseY >= y && mouseY < y + h; } public void render () { noStroke(); fill(190, 200, 220); rect(x-3, y-3, w+6, h+6); image( cpImage, x, y ); if( mousePressed && hover() ) { c = get( mouseX, mouseY ); } fill( c ); rect( x, y+h+10, 20, 20 ); } }