float [] px = { 10.,10.,40.,80.}; float [] py = { 10.,40.,60.,20.}; void draw(){ background(255); for(float t=0.; t<1.; t+=0.01){ float x = px[0]*pow((1 - t),3) + 3*px[1]*t*pow((1 - t),2) + 3*px[2]*pow(t,2)*(1 - t) + px[3]*pow(t,3); float y = py[0]*pow((1 - t),3) + 3*py[1]*t*pow((1 - t),2) + 3*py[2]*pow(t,2)*(1 - t) + py[3]*pow(t,3); point(x,y); } for(int i=0; i<4; i++) rect(px[i],py[i],5,5); } void mouseDragged(){ for(int i=0; i<4; i++) if(dist(mouseX,mouseY,px[i],py[i])<20){ px[i] += (mouseX-pmouseX); py[i] += (mouseY-pmouseY); } }