////////////////////////////////////////////////CODE AND INPUT 1 //////////////////////////////////////// //The example given as input here is a single movement of a three-link chain of lines. float res; float num; int[] data; int z=0; float framesize=1; float alpha1; float alpha2; float alpha3; float frames; float extent; float limit1; float limit2; float limit3; float diamad1; float lenad1; float lenad2; float lenad3; float lenres1; float lenres2; float lenres3; float ang; int deg; void move(float ang1, float amt1, float ang2, float amt2, float ang3, float amt3, // float trc1, float trc2, float trc3, // float len1, float lenad1, float len2, float lenad2, float len3, float lenad3, // float diam1, float diamad1, float diam2, float diamad2, float diam3, float diamad3, // float colR1, float colG1, float colB1, float alpha1, float colR2, float colG2, float colB2, float alpha2, float colR3, float colG3, float colB3, float alpha3) { if (amt1<0) { } float num=amt1/res; //i.e. number of steps in movement (same for all links) float res2=amt2/num; if (amt2<0) { // res2=-(amt2/num);} res2=-res2; } float res3=amt3/num; if (amt3<0) { // res3=-(amt3/num);} res3=-res3; } float lenres1=lenad1/num; float lenres2=lenad2/num; float lenres3=lenad3/num; diamad1=diamad1/num; diamad2=diamad2/num; diamad3=diamad3/num; if (z>=num) { z=0; } if (z % res == 0) { ////// Starting positions: translate (0, 0); rotate (radians(ang1)); pushMatrix(); noStroke(); if (trc1==2) { line (0, 0, len1, 0); //l-1 posn1 (starting position) } translate (len1, 0); rotate (radians(ang2)); noStroke(); if (trc2==2) { line(0, 0, len2, 0); //l-2 (starting position) } translate (len2, 0); rotate (radians(ang3)); noStroke(); if (trc3==2) { line (0, 0, len3, 0); //l-3 (starting position) } translate (len3, 0); popMatrix(); ////// Movements: //translate (300, 200); rotate (radians(res*z)*framesize); //"framesize" determines visible res; amount // must be limited to correct range (num?) len1=len1 + (lenres1*z); if (trc1==0) { noStroke(); } if (trc1==1) { stroke(colR1, colG1, colB1, alpha1); line ( 0, 0, len1, 0); } if (trc1==2) { noStroke(); fill (colR1, colG1, colB1, alpha1); ellipse (len1, 0, diam1+diamad1*z, diam1+diamad1*z); } translate (len1, 0); if (amt2<0) { //// Duplication res2=-res2; } rotate (radians(ang2+res2*z)*framesize); len2=len2 + (lenres2*z); if (trc2==0) { noStroke(); } if (trc2==1) { stroke(colR2, colG2, colB2, alpha2); line (0, 0, len2, 0); } if (trc2==2) noStroke(); fill (colR2, colG2, colB2, alpha2); ellipse (len2, 0, diam2+diamad2*z, diam2+diamad2*z); translate (len2, 0); if (amt3<0) { ////Duplication res3=-res3; } rotate (radians(ang3+res3*z)*framesize); len3=len3 + (lenres3*z); if (trc3==0) { noStroke(); } if (trc3==1) { stroke(colR3, colG3, colB3, alpha3); line (0, 0, len3, 0); } if (trc3==2) { noStroke(); fill (colR3, colG3, colB3, alpha3); ellipse (len3, 0, diam3+diamad3*z, diam3+diamad3*z); } // translate (len3, 0); z=z+1; // counts incremental repeats of move() if (z>=num) { //determines extent of traceform (derived from amt1) z=0; } } } /* _____________________________________________________________ SETUP (applies overall and is stated once for a composition) _____________________________________________________________ */ void setup() { size (1000, 700); smooth(); background (20, 60, 90); stroke(10, 150, 250); strokeWeight(1); frameRate(15); res=.5; //RESOLUTION IN DEGREES } void draw () { /* ____________________________________________________________ MOVEMENTS : INPUT ____________________________________________________________ */ //MOVE 1 extent=30; //must be entered although normally the same as the first link below frames=extent/res; //converted to frames if (frameCount<(frames)) { translate(500, 300); //rotate(radians(-90)); /* * * */ move( 180, 30, 0, 60, 0, -180, 1, 1, 1, 110, 5, 110, 5, 150, 5, 2, 0, 0, 0, 15, 50, 0, 255, 0, 200, 255, 0, 0, 200, 0, 0, 255, 200 ); } else { noLoop(); } // To create file of all frames: //saveFrame("File name-####.tif"); }