// Create the variables. Point[]p = new Point[3]; float shift = 2.0; float spin = 0; // Setup the sketch. void setup(){ size(800, 800); background(0); smooth(); noStroke(); } void draw() { spin = 360.0/(width/2.0/shift); p[0] = new Point(-width/2, height/2); p[1] = new Point(width/2, height/2); p[2] = new Point(0, -height/2); // Centre the spiral translate(width/2, height/2); // Call the spiral function and define the parameters. //if (mousePressed && (mouseButton == LEFT)) { spiral(mouseY, pmouseY, mouseX); //} } // Create the spiral function with 3 parameters. void spiral(float shift1, float shift2, float shift3){ // Control the rotation of the spiral. // Additional rotate()'s can be added for different effects. rotate(spin); rotate(PI/3.0); // Define the fill colour. float r = random(100, 255); float g = random(100, 255); float b = random(100, 255); fill(r, g, b, 10); // Create the triangle triangle(p[0].x+=shift, p[0].y-=shift/(random(shift1)), p[1].x-=shift, p[1].y-=shift/(random(shift2)), p[2].x, p[2].y+=shift*(random(shift3))); // Determine the requirements for recursion. if(p[0].x<0){ // recursive call spiral(shift1, shift2, shift3); } }