class Palette { color[] colors; public Palette( String path ) { this( loadImage( path ) ); } public Palette( PImage img ) { int numPixels = img.width * img.height; colors = new color[numPixels]; for( int i = 0; i < numPixels; ++i ) { colors[i] = img.pixels[i]; } } color GetColor() { return colors[(int)random(colors.length)]; } }