我想根据一个size不断增多的数组 画不断连续向右增长的curveVetex。我目前的想法是参照小球在一段曲线上向右移动的思路,就好比一个曲线是个管道我提前用curvePoint计算出坐标,然后画curveVertex几个参数就用线上的点,但是仍有点问题如图所示,曲线拟合的不太好。老师们能给点提示么?
float x2;
float y2;
float x1;
float y1;
float x3;
float y3;
float x4;
float y4;
float tx;
float ty;
void setup(){
size(300,300);
//x = 0;
//y = 0;
}
void draw(){
background(255);
noFill();
stroke(200);
beginShape();
curveVertex(0, 150);
curveVertex(50, 150);
curveVertex(100, 220);
curveVertex(150, 100);
curveVertex(200, 200);
curveVertex(250, 80);
endShape();
tx = map(mouseX,0,width,0,1);
//ty = map(mouseY,0,height,0,1);
x1 = curvePoint(50,100,150,200,0);
y1 = curvePoint(150,220,100,200,0);
x2 = curvePoint(50,100,150,200,tx*0.33);
y2 = curvePoint(150,220,100,200,tx*0.33);
x3 = curvePoint(50,100,150,200,tx*0.66);
y3 = curvePoint(150,220,100,200,tx*0.66);
x4 = curvePoint(50,100,150,200,tx);
y4 = curvePoint(150,220,100,200,tx);
ellipse(x4,y4,10,10);
ellipse(50,150,10,10);
ellipse(100,220,10,10);
stroke(0);
beginShape();
curveVertex(x1, y1);
curveVertex(x1, y1);
curveVertex(x2, y2);
curveVertex(x3, y3);
curveVertex(x4, y4);
curveVertex(x4, y4);
//curveVertex(250, 80);
endShape();
//println(x + " " + y);}