Bezier Curves
A bezier curve is defined by control points.
There may be 2, 3, 4 or more.
For instance, two points curve:
Three points curve:
Four points curve:
If you look closely at these curves, you can immediately notice:
The main value of Bezier curves for drawing – by moving the points the curve is changing in intuitively obvious way.
Output Screenshots:
Code:
function setup() {
createCanvas(720, 400);
stroke(255);
noFill();
}
function draw() {
background(0);
for (let i = 0; i < 200; i += 20) {
bezier(
mouseX - i / 2.0,
40 + i,
410,
20,
440,
300,
240 - i / 16.0,
300 + i / 8.0
);
}
}
A bezier curve is defined by control points.
There may be 2, 3, 4 or more.
For instance, two points curve:
Three points curve:
Four points curve:
If you look closely at these curves, you can immediately notice:
-
Points are not always on curve. That’s perfectly normal, later we’ll see how the curve is built.
-
The curve order equals the number of points minus one.
For two points we have a linear curve (that’s a straight line), for
three points – quadratic curve (parabolic), for four points – cubic
curve.
-
A curve is always inside the convex hull of control points:
The main value of Bezier curves for drawing – by moving the points the curve is changing in intuitively obvious way.
Output Screenshots:
Code:
function setup() {
createCanvas(720, 400);
stroke(255);
noFill();
}
function draw() {
background(0);
for (let i = 0; i < 200; i += 20) {
bezier(
mouseX - i / 2.0,
40 + i,
410,
20,
440,
300,
240 - i / 16.0,
300 + i / 8.0
);
}
}
No comments:
Post a Comment