int count =24; // number of control vertices int cap=128; // size of array containing control vertices int gr=2; int pts=count*round(pow(2,gr)); float[] x = new float [cap]; float[] y = new float [cap]; int [] locked = new int [cap]; float[] vx = new float [cap*round(pow(2,7))]; float[] vy = new float [cap*round(pow(2,7))]; float[] ox = new float [cap*round(pow(2,7))]; float[] oy = new float [cap*round(pow(2,7))]; float[] ax = new float [cap*round(pow(2,7))]; float[] ay = new float [cap*round(pow(2,7))]; float[] atx = new float [cap*round(pow(2,7))]; float[] aty = new float [cap*round(pow(2,7))]; float[] artx = new float [cap*round(pow(2,7))]; float[] arty = new float [cap*round(pow(2,7))]; float[] asrtx = new float [cap*round(pow(2,7))]; float[] asrty = new float [cap*round(pow(2,7))]; int j=0; float Px = 0.0; float Py = 0.0; // current mouse position int bi=-1; // index of selected vertex, -1 if none selected float lx, ly; // last point of span float[] tt = new float [8]; // values ot Jarek's offset for each recursion float l=138.0; int time=0; int animating =0; int method=2; float mag=20.0; float para=0.3; int locking=1; int sr=64; // number of iterationss to get green curve color black = color(0, 0, 0); color soft = color(250, 240, 190); color red = color(200, 0, 0); color green = color(0, 200, 0); color blue = color(0, 0, 200); color yellow = color(250, 250, 130); color green1 = color(0, 150, 0); color green2 = color(50, 200, 50); color green3 = color(100, 250, 100); void setup() { size(600, 600); // window size and 3D for (int i=0; i-1) {x[bi]=mouseX; y[bi]=mouseY;}; // snap selected vertex to mouse position during dragging if (animating==1) {time++; if (time==pts) {time=0;}; }; stroke(red); strokeWeight(3.0); // draws thinner bundary in black beginShape(LINE_STRIP); for (int i=0; i100) { // if closest vertex is too far bd=600*600; // reinitilize distance squared for (int i=0; ibi; i--) {x[i+1]=x[i]; y[i+1]=y[i]; }; // shift down the rest bi++; x[bi]=Px; y[bi]=Py; count++; // insert new vertex at mouse position pts=count*round(pow(2,gr)); }else {bi=-1;}; // nothing selected }; } void mouseReleased() { // do this when mouse released if ((bi!=-1) && ((x[bi]<0)||(x[bi]>600)||(y[bi]<0)||(y[bi]>600))) // if outside of port { for (int i=bi; ibx) {bx=x[i];}; if (x[i]by) {by=y[i];}; if (y[i]abs(y[n(i)]-y[i])) {float dy=(y[n(i)]-y[i])/2; y[n(i)]-=dy; y[i]+=dy;} else {float dx=(x[n(i)]-x[i])/2; x[n(i)]-=dx; x[i]+=dx;} }; }; if (key=='b') {for (int i=0; i<7; i=i+1) {tt[i]=0.0;};}; // bspline paremeters if (key=='f') {for (int i=0; i<7; i=i+1) {tt[i]=1.0;};}; // four-point paremeters if (key=='j') {for (int i=0; i<7; i=i+1) {tt[i]=0.5;};}; // jarek paremeters if (key=='s') {method++; if (method==3) {method=0;}; println("method = "+method);}; // non-uniform paremeters for z-curve if (key=='-') {gr--; if (gr<0) {gr=0;}; pts=count*round(pow(2,gr));}; if (key=='=') {gr++; if (gr>6) {gr=6;}; pts=count*round(pow(2,gr));}; // adjust recursion level if (key=='z') {sr/=2; if (sr<1) {sr=1;}; println("sr = "+sr); }; if (key=='x') {sr*=2; println("sr = "+sr);}; // adjust parameters for smoothing iterations if (key==',') {para-=0.1; println("para = "+para); }; if (key=='.') {para+=0.1; println("para = "+para); }; // adjust all parameters if (key=='l') {locking=1-locking; println("locking = "+locking);}; if (key=='a') {hold(); replicate(); laplace(); saveLaplace(); // dualControl(); // for testing }; }; void DrawCurve() { snapBack(); beginShape(LINE_STRIP); for (int i=0; i