1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-29 11:10:38 +02:00

figured out how to reuse sketches with data-attribute parameters

This commit is contained in:
Pomax
2020-08-26 21:56:58 -07:00
93 changed files with 5805 additions and 24390 deletions

View File

@@ -0,0 +1,27 @@
let curve;
setup() {
const type = getParameter(`type`, `quadratic`);
curve = (type === `quadratic`) ? Bezier.defaultQuadratic(this) : Bezier.defaultCubic(this);
setMovable(curve.points);
setSlider(`.slide-control`, `steps`, (type === `quadratic`) ? 4 : 8);
}
draw() {
clear();
curve.drawSkeleton();
noFill();
start();
for(let i=0, e=this.steps; i<=e; i++) {
let p = curve.get(i/e);
vertex(p.x, p.y);
}
end();
curve.drawPoints();
setFill(`black`);
text(`Flattened to ${this.steps} segments`, 10, 15);
}