/** PaletteMaker
Dave Bollinger, Jun 2006
http://www.davebollinger.com
updated as of Processing 0123 Beta

Purpose: create a 256-color palette from a larger image by tracing a curve through the image.
Why: to then use that palette image as a source of colors for some other project.
Source image is shown at top, resulting palette is shown at bottom.

Click mouse within upper image to redefine a point on the curve.
The larger square is the curve point that is currently active.
4 points/clicks are required to completely redefine the curve.

If it still doesn't make sense, just click 4 points at random and see what happens.

Press ',' and '.' to decrease/increase palette blur.
Press 's' to save palette image (assumes you're running this locally, not on web!)

Sample results (all from the same demo image):









*/ Texture tex; Curve crv; Palette pal; int blurAmount=3; void setup() { size(256,280); tex = new Texture(this, "fruit.jpg"); // derived from pdphoto.org crv = new Curve(this); pal = new Palette(this); createPalette(); noLoop(); } void draw() { background(0); tex.draw(); crv.draw(0, 0); pal.draw(0, 270, 1, 10); } void createPalette() { pal.scrape(tex, crv); for (int i=0; i 10) blurAmount = 10; println("blurAmount = " + blurAmount); createPalette(); redraw(); } if (key==',') { if (--blurAmount < 0) blurAmount = 0; println("blurAmount = " + blurAmount); createPalette(); redraw(); } } void mousePressed() { if (mouseButton==RIGHT) return; if ((mouseX>=0) && (mouseX<256) && (mouseY>=0) && (mouseY<256)) { println("Setting curve point " + crv.cindex + " to " + mouseX + ", " + mouseY); crv.set(mouseX, mouseY); createPalette(); redraw(); } }