如何沿着贝塞尔路径绘制形状
How to draw shapes along a bezier path
我想沿着贝塞尔路径绘制一系列椭圆,但我正在努力绘制除路径线之外的任何其他内容。我根本不需要它移动。到目前为止我有:
void setup() {
size(150, 150);
background(255);
smooth();
// Don't show where control points are
noFill();
stroke(0);
beginShape();
vertex(50, 75); // first point
bezierVertex(25, 25, 125, 25, 100, 75);
endShape();
}
如何绘制椭圆以遵循贝塞尔曲线路径而不是直线?
为什么您希望该代码绘制圆圈?它不包含对 ellipse()
函数的任何调用。
无论如何,听起来您正在寻找 bezierPoint()
函数:
noFill();
bezier(85, 20, 10, 10, 90, 90, 15, 80);
fill(255);
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
float x = bezierPoint(85, 10, 90, 15, t);
float y = bezierPoint(20, 10, 90, 80, t);
ellipse(x, y, 5, 5);
}
(来源:processing.org)
与往常一样,可以在 the reference 中找到更多信息。
我想沿着贝塞尔路径绘制一系列椭圆,但我正在努力绘制除路径线之外的任何其他内容。我根本不需要它移动。到目前为止我有:
void setup() {
size(150, 150);
background(255);
smooth();
// Don't show where control points are
noFill();
stroke(0);
beginShape();
vertex(50, 75); // first point
bezierVertex(25, 25, 125, 25, 100, 75);
endShape();
}
如何绘制椭圆以遵循贝塞尔曲线路径而不是直线?
为什么您希望该代码绘制圆圈?它不包含对 ellipse()
函数的任何调用。
无论如何,听起来您正在寻找 bezierPoint()
函数:
noFill();
bezier(85, 20, 10, 10, 90, 90, 15, 80);
fill(255);
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
float x = bezierPoint(85, 10, 90, 15, t);
float y = bezierPoint(20, 10, 90, 80, t);
ellipse(x, y, 5, 5);
}
(来源:processing.org)
与往常一样,可以在 the reference 中找到更多信息。