ira.
thank you so much. that's definately a start, but i'm not sure how to use it in a way that would conect the endpoints of a shape that already exists.
lets say i'm drawing a form from a set of points in a 2D array OR importing an svg file
is this possible? it has to be. right?
Code:
float[][] punkte = {
{-71.927734375,59.08203125, -73.017578125,62.310546875,-56.22265625,23.654296875, -56.22265625,23.654296875},
{-56.22265625,23.654296875, -48.1884765625,31.69921875,-45.5361328125,62.13671875, -45.5361328125,62.13671875},
{56.7978515625,56.201171875, 58.013671875,45.609375,60.8447265625,22.1328125, 60.8447265625,22.1328125},
{60.8447265625,22.1328125, 68.57421875,26.56640625,83.623046875,36.10546875, 83.623046875,36.10546875},
{25.4013671875,57.4453125, 33.263671875,50.77734375,51.0400390625,25.8125, 51.0400390625,25.8125},
{51.0400390625,25.8125, 52.486328125,40.0859375,52.6318359375,68.75, 52.6318359375,68.75},
{20.564453125,47.767578125, 36.150390625,42.18359375,38.6318359375,20.73828125, 38.6318359375,20.73828125},
{38.6318359375,20.73828125, 33.021484375,19.974609375,21.8017578125,18.44921875, 21.8017578125,18.44921875},
{-22.021484375,-4.56640625, 24.0966796875,15.19921875,-89.640625,69.22265625, -89.640625,69.22265625},
{-89.640625,69.22265625, -108.9658203125,15.705078125,-23.482421875,-34.826171875, -23.482421875,-34.826171875},
{-92.220703125,20.671875, -85.2998046875,17.984375,-65.8505859375,4.69140625, -65.8505859375,4.69140625},
{-65.8505859375,4.69140625, -73.4619140625,-0.201171875,-89.03515625,-9.400390625, -89.03515625,-9.400390625},
{-80.3876953125,24.072265625, -83.1376953125,25.328125,-88.31640625,28.4296875, -88.31640625,28.4296875},
{-80.3876953125,24.072265625, -53.7998046875,9.638671875,-80.4501953125,59.298828125, -80.4501953125,59.298828125},
{80.4765625,-11.302734375, 77.302734375,-10.7109375,49.9462890625,9.5546875, 49.9462890625,9.5546875},
{49.9462890625,9.5546875, 59.5380859375,12.54296875,77.900390625,20.544921875, 77.900390625,20.544921875},
{-36.5595703125,26.76953125, -85.8203125,-15.892578125,36.689453125,13.2578125, 36.689453125,13.2578125},
{36.689453125,13.2578125, 30.7236328125,12.830078125,18.7919921875,11.97265625, 18.7919921875,11.97265625},
{-46.7431640625,24.447265625, -46.9462890625,33.951171875,-42.1171875,51.84765625, -42.1171875,51.84765625},
{70.5498046875,-15.880859375, 65.34765625,-8.748046875,50.84375,-1.169921875, 50.84375,-1.169921875},
{50.84375,-1.169921875, 54.2109375,-15.1640625,55.9775390625,-43.7265625, 55.9775390625,-43.7265625},
{-0.1044921875,-88.640625, -5.8427734375,-49.345703125,41.59375,-4.455078125, 41.59375,-4.455078125},
{41.59375,-4.455078125, 44.697265625,-15.69140625,48.0029296875,-38.71484375, 48.0029296875,-38.71484375},
{8.591796875,-26.03125, 23.5341796875,-44.333984375,65.4453125,-53.099609375, 65.4453125,-53.099609375},
{65.4453125,-53.099609375, 88.1396484375,-24.087890625,92.5400390625,58.59375, 92.5400390625,58.59375},
{92.5400390625,58.59375, 91.6259765625,73.953125,31.3857421875,90.791015625, 31.3857421875,90.791015625},
{31.3857421875,90.791015625, 3.2421875,95.66015625,9.740234375,1.482421875, 9.740234375,1.482421875},
{-61.8544921875,-46.1328125, -49.48046875,-37.4609375,-34.576171875,-15.93359375, -34.576171875,-15.93359375},
{-34.576171875,-15.93359375, -6.2568359375,-35.439453125,-10.9765625,-94.896484375, -10.9765625,-94.896484375},
{-89.91015625,-16.556640625, -87.64453125,-17.984375,-68.1181640625,-3.970703125, -68.1181640625,-3.970703125},
{-68.1181640625,-3.970703125, -63.828125,-2.685546875,-67.5048828125,-45.21484375, -67.5048828125,-45.21484375}};
int nodeCount = punkte.length;//4;
float nodeSize = 3.0;
Point2D[] pts = new Point2D[nodeCount];
void setup(){
size(500, 500);
background(255);
// calc random points
for (int i=0; i<pts.length; i++){
pts[i] = new Point2D(punkte[i][0], punkte[i][1]);
}
}
void draw(){
background(255);
translate(width*0.5,height*0.5);
strokeWeight(0.5);
scale(2);
// argument changes spline interpolation
curveTightness(-0.5);
noFill();
stroke(0,255,255);
// draw the starting/original form
for(int i=0; i<punkte.length; i++) {
//println(punkte[i][0]);
bezier(
punkte[i][0], punkte[i][1],
punkte[i][2], punkte[i][3],
punkte[i][4], punkte[i][5],
punkte[i][6], punkte[i][7]);
}
// draw spline curve
// look carefully at the order of the points passed to curve()
stroke(0);
beginShape();
curve(pts[0].x, pts[0].y, pts[0].x, pts[0].y, pts[1].x, pts[1].y, pts[2].x, pts[2].y);
for (int i=0; i<pts.length-3; i++){
curve(pts[i].x, pts[i].y, pts[i+1].x, pts[i+1].y, pts[i+2].x, pts[i+2].y, pts[i+3].x, pts[i+3].y);
}
curve(pts[pts.length-3].x, pts[pts.length-3].y, pts[pts.length-2].x, pts[pts.length-2].y, pts[pts.length-1].x, pts[pts.length-1].y, pts[pts.length-1].x, pts[pts.length-1].y);
// draw nodes
noStroke();
for (int i=0; i<pts.length; i++){
pushMatrix();
translate(pts[i].x, pts[i].y);
fill(100);
if (i==0 || i == pts.length-1){
fill(255, 75, 0);
}
ellipse(0,0, nodeSize,nodeSize);
popMatrix();
}
}
class Point2D{
float x, y;
Point2D(){
}
Point2D(float x, float y){
this.x = x;
this.y = y;
}
}
Ken