import geomerative.*; class bezierstroke { float startsize,endsize,linewidth,mpfract,raisefract,bezierfract; bezierstroke(float _s,float _e,float _l,float _m,float _r,float _b){ startsize=_s; endsize=_e; linewidth=_l; mpfract=_m; raisefract=_r; bezierfract=_b; } void drawstroke(RPoint start,RPoint end) { ellipse(start.x,start.y,startsize,startsize); ellipse(end.x,end.y,endsize,endsize); RPoint mp=new RPoint(start.x+((end.x-start.x)*mpfract),(start.y+((end.y-start.y)*mpfract))-((getHeight()-(start.y+((end.y-start.y)*mpfract)))*raisefract)); RPoint bv=new RPoint((end.x-start.x)*bezierfract,(end.y-start.y)*bezierfract); RPoint b1=new RPoint(mp.x-bv.x,mp.y-bv.y); RPoint b2=new RPoint(mp.x+bv.x,mp.y+bv.y); beginShape(); vertex(start.x,start.y); bezierVertex(start.x,start.y,b1.x,b1.y-(linewidth/2),mp.x,mp.y-(linewidth/2)); bezierVertex(b2.x,b2.y-(linewidth/2),end.x,end.y,end.x,end.y); bezierVertex(end.x,end.y,b2.x,b2.y+(linewidth/2),mp.x,mp.y+(linewidth/2)); bezierVertex(b1.x,b1.y+(linewidth/2),start.x,start.y,start.x,start.y); endShape(); } } RPoint perpoint(RPoint p1,RPoint p2,float d) { //returns a point left distance d of perpendicular line between points float h=atan2(p2.y-p1.y,p2.x-p1.x); return new RPoint(p2.x+(cos(h+HALF_PI)*d),p2.y+(sin(h+HALF_PI)*d)); } class gradientstroke { float startsize,endsize,mpfract,raisefract,bezierfract; float[] transpos; float[] transamt; color col; gradientstroke(float _s,float _e,float[] _p, float[] _a,color _c){ startsize=_s; endsize=_e; transpos=_p; transamt=_a; col=_c; } void drawstroke(RPoint Sp,RPoint Ep) { drawstroke(Sp,Ep,col); } void drawstroke(RPoint Sp,RPoint Ep,color _col) { noStroke(); fill(red(_col),green(_col),blue(_col),255); //put ellipses in a seperate layer //ellipse(Sp.x,Sp.y,startsize,startsize); //ellipse(Ep.x,Ep.y,endsize,endsize); //construct quads along path //path is straight, curve comes from 3D/ raise //how to deal with badly formatted control arrays? bother? //3d stage in between noFill(); float spos=0.0; float step=.001; //optimise //quad corner points //these are perpedicular on the screen as we are making a gradient line system RPoint L0,L1,p0,p1,p2,p3; p0=new RPoint(0,0); p1=p0; L0=Sp; boolean notfirst=false; for (int i=0;i