mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-21 16:02:08 +02:00
figured out how to reuse sketches with data-attribute parameters
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
let curve;
|
||||
|
||||
setup() {
|
||||
this.curve = Bezier.defaultCubic(this);
|
||||
setMovable(this.curve.points);
|
||||
curve = Bezier.defaultCubic(this);
|
||||
setMovable(curve.points);
|
||||
|
||||
const inputs = findAll(`input[type=range]`);
|
||||
if (inputs) {
|
||||
const ratios = inputs.map(i => parseFloat(i.value));
|
||||
this.curve.setRatios(ratios);
|
||||
curve.setRatios(ratios);
|
||||
|
||||
inputs.forEach((input,pos) => {
|
||||
const span = input.nextSibling;
|
||||
input.listen(`input`, evt => {
|
||||
const value = parseFloat(evt.target.value);
|
||||
span.textContent = ratios[pos] = value;
|
||||
this.curve.update();
|
||||
curve.update();
|
||||
this.redraw();
|
||||
});
|
||||
})
|
||||
@@ -21,12 +23,7 @@ setup() {
|
||||
|
||||
draw() {
|
||||
clear();
|
||||
const curve = this.curve;
|
||||
curve.drawSkeleton();
|
||||
curve.drawCurve();
|
||||
curve.drawPoints();
|
||||
}
|
||||
|
||||
onMouseMove() {
|
||||
redraw();
|
||||
}
|
||||
|
Reference in New Issue
Block a user