PathShape p; float t; void setup() { size(400,400); p=new PathShape(0,0, 1); p.moveTo(0,0); p.curveTo(300,0, 200,200, 400,400); p.curveTo(200,350, 200,50, 400,0); p.curveTo(400,200, 100,300, 0,400); } void draw() { // background(200); noFill(); p.draw(); fill(255); t=t+0.01; if(t>1) t=0; float pos [] = p.calcPosAndNormal(t); // draw ellipse at position t on the path ellipse(pos[0],pos[1], 20,20); // draw normal at position t line(pos[0]+pos[2]*30,pos[1]+pos[3]*30, pos[0]-pos[2]*30,pos[1]-pos[3]*30); } class PathShape extends Shape { float pt[]; int num; public PathShape(float _x,float _y,float _rad) { super(_x,_y,_rad); // Calls Shape's constructor pt=new float[10*6+2]; } void moveTo(float _x,float _y) { pt[0]=_x; pt[1]=_y; } void curveTo(float x1,float y1, float x2,float y2, float x3,float y3) { int index=num*6; // check to see if we have space for more points if(index==pt.length) { // create an array of twice the size float [] tmp=new float[pt.length*2]; // copy the values from the old array for(int i=0; i