curverDrawer myDrawer; boolean showPoints = false; boolean fillShape = false; short timer = 0; //----------------------------------------- class curverDrawer { byte arms,state,myFill; float theta, radius,c1rad,c2rad; float gRot, c1Rot, c2Rot; float gRotPos, c1RotPos, c2RotPos; float radiusRate,radiusVal,c1Rate,c1Val,c2Rate,c2Val; byte radiusMult,c1Mult,c2Mult; float qx1,qx2,qy1,qy2,qcx1,qcx2,qcy1,qcy2; short myHue,hueOff; curverDrawer() { gRotPos = 0; c1RotPos = 0; c2RotPos = 0; gRot = random(-TWO_PI / 720,TWO_PI / 720); c1Rot = random(-TWO_PI / 720,TWO_PI / 720); c2Rot = random(-TWO_PI / 720,TWO_PI / 720); radiusRate = random(-TWO_PI / 720,TWO_PI / 720); radiusVal = 0; c1Rate = random(-TWO_PI / 720,TWO_PI / 720); c1Val = 0; c2Rate = random(-TWO_PI / 720,TWO_PI / 720); c2Val = 0; radiusMult = (byte)(random(20,100)); c1Mult = (byte)(random(30,125)); c2Mult = (byte)(random(30,125)); arms = (byte)(random(5,35)); theta = TWO_PI/arms; radius = random(50,300); c1rad = random(50,300); c2rad = random(50,300); state = 0; myFill = 0; } void update() { if (state == 0) { if (myFill == 125) { state = 1; myFill = 126; println("check"); } else { myFill++; } } else if (state == 2) { if (myFill <= 0) { state = 3; timer = 0; } else { myFill--; } } for (byte i = 0; i < arms; i++) { qx1 = (width/2) + ((radius + (radiusMult * sin(radiusVal))) * cos((theta * i) + gRotPos)); qy1 = (height/2) + ((radius + (radiusMult * sin(radiusVal))) * sin((theta * i) + gRotPos)); qx2 = (width/2) + ((radius + (radiusMult * sin(radiusVal))) * cos((theta * (i+1))+ gRotPos)); qy2 = (height/2) + ((radius + (radiusMult * sin(radiusVal))) * sin((theta * (i+1))+ gRotPos)); qcx1 = (width/2) + ((c1rad + (c1Mult * sin(c1Val))) * cos((theta * i) + c1RotPos)); qcy1 = (height/2) + ((c1rad + (c1Mult * sin(c1Val))) * sin((theta * i) + c1RotPos)); qcx2 = (width/2) + ((c2rad + (c2Mult * sin(c2Val))) * cos((theta * i) + c2RotPos)); qcy2 = (height/2) + ((c2rad + (c2Mult * sin(c2Val))) * sin((theta * i) + c2RotPos)); if (showPoints) { stroke(126,myFill/2); if (fillShape) { fill(myHue,125,125,myFill/2); ellipse(qx1,qy1,10,10); fill(myHue,125,125,myFill/10); ellipse(qx2,qy2,15,15); fill(myHue,125,125,myFill/5); ellipse(qcx1,qcy1,10,10); fill(myHue,125,125,myFill/5); ellipse(qcx2,qcy2,15,15); } else { fill(125,myFill/2); ellipse(qx1,qy1,10,10); fill(64,myFill/10); ellipse(qx2,qy2,15,15); fill(10,myFill/5); ellipse(qcx1,qcy1,10,10); fill(10,myFill/5); ellipse(qcx2,qcy2,15,15); } } if (fillShape) { myHue = (short)(((126/arms)*i) + hueOff); if (myHue > 126) { myHue -= 126; } if (state == 0) { fill(myHue,125,125,myFill / 5); } else if ((state == 2) || (state == 3)) { fill(myHue,125,125,myFill / 5); } else { fill(myHue,125,125,25); } } else { noFill(); } stroke(126,myFill); bezier(qx1,qy1,qcx1,qcy1,qcx2,qcy2,qx2,qy2); } gRotPos += gRot; c1RotPos += c1Rot; c2RotPos += c2Rot; radiusVal += radiusRate; if (radiusVal > TWO_PI) { radiusVal = 0; } c1Val += c1Rate; if (c1Val > TWO_PI) { c1Val = 0; } c2Val += c2Rate; if (c2Val > TWO_PI) { c2Val = 0; } if (hueOff == 126) { hueOff = 0; } else { hueOff++; } } } //----------------------------------------- void setup() { size(700,700); colorMode(HSB,126); noFill(); smooth(); myDrawer = new curverDrawer(); } //----------------------------------------- void draw() { background(40); myDrawer.update(); if (timer == 2000) { myDrawer.state = 2; } if (myDrawer.state == 3) { myDrawer = new curverDrawer(); } timer++; } //----------------------------------------- void mouseClicked() { println("X: " + mouseX + " ||| Y: " + mouseY); if (fillShape) { fillShape = false; } else { fillShape = true; } }