curverDrawer myDrawer; boolean showPoints = false; boolean fillShape = false; short timer = 0; //----------------------------------------- class curverDrawer { byte arms,links,state,myFill; float theta; float[] radius,radius2,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() { links = (byte)(random(5,9)); qx1 = new float[links]; qx2 = new float[links]; qy1 = new float[links]; qy2 = new float[links]; qcx1 = new float[links]; qcx2 = new float[links]; qcy1 = new float[links]; qcy2 = new float[links]; radiusRate = new float[links]; radiusVal = new float[links]; c1Rate = new float[links]; c2Rate = new float[links]; c1Val = new float[links]; c2Val = new float[links]; radiusMult = new byte[links]; c1Mult = new byte[links]; c2Mult = new byte[links]; radius = new float[links]; radius2 = new float[links]; c1rad = new float[links]; c2rad = new float[links]; gRot = new float[links]; c1Rot = new float[links]; c2Rot = new float[links]; gRotPos = new float[links]; c1RotPos = new float[links]; c2RotPos = new float[links]; arms = (byte)(random(5,9)); theta = TWO_PI/arms; for (byte i = 0; i < links; i++) { gRotPos[i] = 0; c1RotPos[i] = 0; c2RotPos[i] = 0; gRot[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); c1Rot[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); c2Rot[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); radiusRate[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); radiusVal[i] = 0; c1Rate[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); c1Val[i] = 0; c2Rate[i] = random(-TWO_PI / (720 * links),TWO_PI / (720 * links)); c2Val[i] = 0; radiusMult[i] = (byte)(random(20*(1/links),100*(1/links))); c1Mult[i] = (byte)(random(30*(1/links),125*(1/links))); c2Mult[i] = (byte)(random(30*(1/links),125*(1/links))); radius[i] = random(50,300); c1rad[i] = random(50,300); c2rad[i] = 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++) { for (byte k = 0; k < links; k++) { qx1[k] = (width/2) + ((radius[k] + (radiusMult[k] * sin(radiusVal[k]))) * cos((theta * i) + gRotPos[k])); qy1[k] = (height/2) + ((radius[k] + (radiusMult[k] * sin(radiusVal[k]))) * sin((theta * i) + gRotPos[k])); if (k == (links - 1)) { qx2[k] = (width/2) + ((radius[0] + (radiusMult[0] * sin(radiusVal[0]))) * cos((theta * (i+1))+ gRotPos[0])); qy2[k] = (height/2) + ((radius[0] + (radiusMult[0] * sin(radiusVal[0]))) * sin((theta * (i+1))+ gRotPos[0])); } else { qx2[k] = (width/2) + ((radius[k+1] + (radiusMult[k+1] * sin(radiusVal[k+1]))) * cos((theta * (i))+ gRotPos[k+1])); qy2[k] = (height/2) + ((radius[k+1] + (radiusMult[k+1] * sin(radiusVal[k+1]))) * sin((theta * (i))+ gRotPos[k+1])); } qcx1[k] = (width/2) + ((c1rad[k] + (c1Mult[k] * sin(c1Val[k]))) * cos((theta * i) + c1RotPos[k])); qcy1[k] = (height/2) + ((c1rad[k] + (c1Mult[k] * sin(c1Val[k]))) * sin((theta * i) + c1RotPos[k])); qcx2[k] = (width/2) + ((c2rad[k] + (c2Mult[k] * sin(c2Val[k]))) * cos((theta * i) + c2RotPos[k])); qcy2[k] = (height/2) + ((c2rad[k] + (c2Mult[k] * sin(c2Val[k]))) * sin((theta * i) + c2RotPos[k])); } /* 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); for (byte l = 0; l < links; l++) { // stroke((126/links) * l,(126/links) * l,126); myHue = (short)(((126/arms/links)*i*l) + hueOff); if (myHue > 126) { myHue -= 126; } // stroke(myHue,126,126,myFill); stroke(myHue,126,126,25); bezier(qx1[l],qy1[l],qcx1[l],qcy1[l],qcx2[l],qcy2[l],qx2[l],qy2[l]); gRotPos[l] += gRot[l]; c1RotPos[l] += c1Rot[l]; c2RotPos[l] += c2Rot[l]; radiusVal[l] += radiusRate[l]; if (radiusVal[l] > TWO_PI) { radiusVal[l] = 0; } c1Val[l] += c1Rate[l]; if (c1Val[l] > TWO_PI) { c1Val[l] = 0; } c2Val[l] += c2Rate[l]; if (c2Val[l] > TWO_PI) { c2Val[l] = 0; } } } if (hueOff == 126) { hueOff = 0; } else { hueOff++; } } } //----------------------------------------- void setup() { size(700,700); colorMode(HSB,126); noFill(); smooth(); background(40); 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; } }