float[][] anpts = { new float[] { 88f, 98f } ,new float[] { 61f, 329f } }; float[][] cvpts = { new float[] { 297f, 84f } ,new float[] { 293f,335f } }; char [] ad = { 'a', 'd'}; char [] bc = { 'b', 'c'}; Handle[] anchors = new Handle[2]; Handle[] curvs = new Handle[2]; PFont myFont; String string ; float squishy = 0.0; PSlider slider1 ; color bkColor = color(220,255,255); void setup() { size( 600, 500 ); slider1 = new PSlider (5, 480, 150, 15, "squishiness= ", -10.0, 10.0); slider1.initPos(0.0); for (int i=0; i<2; i++) { { anchors[i] = new Handle( anpts[i][0], anpts[i][1], 10, color(0,255,200), "Square" ); curvs[i] = new Handle( cvpts[i][0], cvpts[i][1], 10, color(255,255,100), "circle" ); } } myFont = loadFont("Verdana-Bold-12.vlw"); textFont(myFont); ellipseMode( CORNER ); framerate(30); } void draw() { squishy = slider1.slv; curveTightness(squishy); background(bkColor); fill(0); rect(0,0,600,400); fill(50); text("Created by Koo-Chul Lee (Nov./10/'05))", 330,15); slider1.display(); for (int i=0; i<2; i++) { anchors[i].display(); curvs[i].display(); } fill(255); for (int i=0; i<2; i++) { string = ad[i] + " ("+nf(anpts[i][0], 3,0)+", "+nf(anpts[i][1], 3,0) + ")"; text(string, anpts[i][0]-20, anpts[i][1]-8); string = bc[i] + " ("+nf(cvpts[i][0], 3,0)+", "+nf(cvpts[i][1], 3,0) + ")"; text(string, cvpts[i][0]-20, cvpts[i][1]-8); } updatePos(); stroke(255); curve (anpts[0][0],anpts[0][1],cvpts[0][0],cvpts[0][1], cvpts[1][0],cvpts[1][1],anpts[1][0],anpts[1][1]); fill(0); text("curveTightness( " + nfs(slider1.slv, 1,2) + " )", 10, 420); text("curve( " + nf(anpts[0][0], 3,0) + ", " + nf(anpts[0][1], 3,0) + ", " + nf(cvpts[0][0], 3,0) + ", " + nf(cvpts[0][1], 3,0) + ", " + nf(cvpts[1][0], 3,0) + ", " + nf(cvpts[1][1], 3,0) + ", " + nf(anpts[1][0], 3,0) + ", " + nf(anpts[1][1], 3,0) + " )", 10, 440); stroke(0); } void updatePos() { for (int i=0; i<2; i++) { anpts[i][0] = anchors[i].x + anchors[i].w/2; anpts[i][1] = anchors[i].y + anchors[i].w/2; cvpts[i][0] = curvs[i].x + curvs[i].w/2; cvpts[i][1] = curvs[i].y + curvs[i].w/2; } } void mousePressed() { slider1.dragThumb(); if(slider1.over()) slider1.changeValue(); for (int i=0; i<2; i++) { anchors[i].drag(); curvs[i].drag(); } } void mouseReleased() { slider1.dragThumb(); if(slider1.over()) slider1.changeValue(); for (int i=0; i<2; i++) { anchors[i].drag(); curvs[i].drag(); } }