// Tie Dye // David Bollinger, May 2006 // http://www.davebollinger.com // for Processing 0115 Beta // random number seed int currentSeed = 0; // number of "octaves" of waviness int numOctaves = 3; // number of waves, need 3 (H,S,B) for each octave int numWaves = numOctaves * 3; // decrease in intensity at each subsequent octave past first float falloff = 0.75; // array of wave generators Waver[] waves; // draw only grayscale brightness? boolean bGrayscaleMode = false; // draw each pattern opaque instead of overlaid on previous? boolean bOpaqueMode = true; // used to animate and step through rows of image int currenty = 0; // number of rows processed per frame int rowsperframe = 10; // for very first image we draw opaque regardless boolean bVeryFirstImage = true; void setup() { size(480,480,P3D); framerate(30); waves = new Waver[numWaves]; for (int i=0; i>1)&0xff0000) + ((((c&0xff00)+(p&0xff00))>>1)&0xff00) + ((((c&0xff)+(p&0xff))>>1)&0xff); pixels[idx++] = mix; } } } updatePixels(); currenty += rowsperframe; if (currenty >= height) { next(); } } void next() { bVeryFirstImage = (currentSeed == 0); randomSeed(currentSeed++); for (int i=0; i 1.0) value = 1.0; return value; } // clamp to 0..1 using sine wave float clamp_sine(float value) { while (value < 0.0) value += 1.0; while (value > 1.0) value -= 1.0; value = sin(value * PI); return value; } // clamps to 0..1 using a triangle wave // (better for hue than clamp_sine, otherwise bunching up around reds/purples occurs) float clamp_triangle(float value) { while (value < 0.0) value += 2.0; while (value > 2.0) value -= 2.0; if (value > 1.0) value = 2.0 - value; return value; } // gamma adjust float stretch(float value, float gamma) { float rgamma = (gamma <= 0.0) ? 1.0 : 1.0 / gamma; return pow(value,rgamma); } // compress towards midrange (could expand too, but not used here) float squish(float value, float minim, float range) { return minim + value * range; } // constant offset with wrap float rotate(float value, float offset) { value += offset; while (value > 1.0) value -= 1.0; return value; } // uh, invert float invert(float value) { return 1.0 - value; }