// for some reason I have to draw 2 beziers for this. // Does bezierPoint and beierTangent work voor bezierCurve as well? // void drawBezier() { for (int iB = 0; iB <= res; iB++) { // values for angle, res and w can be random angle = random(PI); // electrifying effect res = 40; w = random(100,width/2); float t = iB / float(res); // Get the location of the point float x = bezierPoint(gCur[0], gCur[2], gCur[4], gCur[6], t); float x2 = bezierPoint(gCur[6], gCur[8], gCur[10], gCur[12], t); float y = bezierPoint(gCur[1], gCur[3], gCur[5], gCur[7], t); float y2 = bezierPoint(gCur[7], gCur[9], gCur[11], gCur[13],t); // Get the tangent points float tx = bezierTangent(gCur[0], gCur[2], gCur[4], gCur[6], t); float tx2 = bezierTangent(gCur[6], gCur[8], gCur[10], gCur[12], t); float ty = bezierTangent(gCur[1], gCur[3], gCur[5], gCur[7], t); float ty2 = bezierTangent(gCur[7], gCur[9], gCur[11], gCur[13],t); strokeWeight(1); // Calculate an angle from the tangent points for segmentA float angA = atan2(ty, tx); //println(angA); angA += angle; // draw the lines on segA stroke(255,int(random(1,12)*12),0,30); line(x + cos(angA) * -w, y + sin(angA) * -w, x + cos(angA) * w, y + sin(angA) * w); // Calculate an angle from the tangent points for segmentB float angB = atan2(ty2, tx2); angB += angle; // draw the lines on segB line(x2 + cos(angB) * -w, y2 + sin(angB) * -w, x2 + cos(angB) * w, y2 + sin(angB) * w); // here we draw the points on the curves s = random(12); noStroke(); fill(210,255,10,random(20,90)); ellipse(x, y, s, s); ellipse(x2, y2, s, s); noFill(); } }