// 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 //angle = HALF_PI; // HALF_PI is loodrecht op de curve PI is met de curve mee res = 50; //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(155,0,0,30); line(x + cos(angA) * -w, y + sin(angA) * -w, x + cos(angA) * w, y + sin(angA) * w); //line(x + sin(angA) * -w, y + sin(angA) * w, x + sin(angA) * w, y + sin(angA) * -w ); // line(x-w,y+(w/2),x+w,y-(w/2)); //line(x-w,y+w,x+w,y-w); //ellipse(x-w,y+w,s,s); //ellipse(x+w,y-w,s,s); // 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); //line(x2 + cos(angB) * -w, y2 + cos(angB) * w, x2 + cos(angB) * w, y2 + cos(angB) * -w ); //stroke(255); //line(x2 + sin(angB) * -w, y2 + sin(angB) * w, x2 + sin(angB) * w, y2 + sin(angB) * -w ); //line(x2-w,y2+w,x2+w,y2-w); //ellipse(x2-w,y2+w,s,s); //ellipse(x2+w,y2-w,s,s); //stroke(255,0,0); //bezier(gCur[0], gCur[1], gCur[2], gCur[3], gCur[4], gCur[5], gCur[6], gCur[7]); //bezier(gCur[6], gCur[7], gCur[8], gCur[9], gCur[10], gCur[11], gCur[12], gCur[13]); // here we draw the points on the curves s = random(12); noStroke(); fill(210,210,255,random(20,100)); ellipse(x, y, s, s); // fill(210,210,255,70); ellipse(x2, y2, s, s); noFill(); } }