// IKEDA attractor variations // based on Clifford A. Pickover's algorhythm in "Computers and the Imagination" // adapted by Patrick H. Lauke aka redux / www.splintered.co.uk // 31 Oct 2004 int dim; float c1; float c2; float c3; float rho; float basecolor; float complexity; int i; float x; float y; float j; float k; int ji; int ki; float current; float scale; float xoff; float yoff; float xt; float yt; float temp; float sin_temp; float cos_temp; float randomizer; void setup() { // initialise a few parameters basecolor=255; dim=300; scale = dim/3.75; complexity = dim*100; xoff = dim/3; yoff = dim/1.7; c1 = 0.4; c2 = 0.85; c3 = 0.6; rho = 1.0; randomizer = 0; // create the drawing area and fill it with background color size(dim,dim); background(basecolor); // set framerate framerate(25); } void loop() { // an empty loop...simply waits for mouse input } void mousePressed() { // wipe the drawing area background(basecolor); // randomize randomizer = random(0.3); } void mouseMoved() { // alter key parameters based on mouse position c3=float(mouseX)/float(dim)*10+5.9; rho=float(mouseY)/float(dim)*0.2+0.9; // redraw the shape ikeda(); } void ikeda() { x = 0.1; y = 0.1; for (i=0; i <= complexity; i++) { // calculate position of new point temp = c1 - c3 / (1.0 + randomizer * 3 + x * x + y * y); sin_temp = sin(temp); cos_temp = cos(temp); xt = rho + c2 * (x * cos_temp - y * sin_temp); yt = randomizer + c2 * (x * sin_temp + y * cos_temp); // adapt calculated coordinates to current drawing area j = xt * scale + xoff; k = yt * scale + yoff; // normalise the point's position to the nearest integer ji = int(j); ki = int(k); // grab the red component of the point's current color current = red(get(ji,ki)); // set the drawing color to the current color minus a small offset stroke(current-1); // and draw the point point(j,k); // assign new position as starting point for next iteration x = xt; y = yt; } }