import processing.opengl.*; // usefull colors final color WHITE = color(255); final color PURPLE = color(237,22,223); final color RED = color(157,17,0); final color GRAY = color(127,125,123); final color DARK_GRAY = color(58,57,56); Node node; // the node object float angle; // the node angle boolean fix; // fix events release void setup() { size(700,350);//OPENGL); background(WHITE); textFont( loadFont("BitstreamVeraSans-Bold-10.vlw") ); // init the node shape node = new Node( width/2, height/2, 300 ); node.amplitude(100); node.bend(20,40,Node.RANDOM_POINT); node.bend(70,Node.FIRST_ENDPOINT); node.complexity(13); node.bend(300,Node.SECOND_ENDPOINT); } void draw() { noStroke(); fill(255,255,255,100); rect(0,0,width,height); // draw the node bezierDetail(20); stroke(GRAY); noFill(); node.draw(); // draw both extrenal lines float[] param1 = node.get( Node.FIRST_ENDPOINT ); float[] param2 = node.get( Node.SECOND_ENDPOINT ); bezier( 100, 70, textWidth("a node"), 70, param1[0]+param1[2], param1[1]+param1[2], param1[0], param1[1] ); bezier( width, height, width, height, param2[0]-param2[2], param2[1]-param2[2], param2[0], param2[1] ); // text fill(DARK_GRAY); text( "always in progress", 98, 75 ); } ////////////// EVENTs void mouseReleased() { if ( !fix ) { node.move(mouseX,mouseY); node.update( radians(angle), second() ); // <-- use the current second value as random value } fix = false; } void mouseDragged() { fix = true; if ( keyPressed ) { float[] ncp = node.get( Node.CENTER_POINT ); if ( keyCode==SHIFT ) node.rotate( angle=atan2(mouseY- ncp[1], mouseX-ncp[0]) ); // rotate the node shape if ( keyCode==ALT ) node.gap( dist(ncp[0],ncp[1],mouseX,mouseY) ); // separate the node's endpoints } // or move all node points except the endpoints else node.move(mouseX,mouseY,true); }