mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-28 18:49:57 +02:00
added sliders to sketches that should have one, improved lazy loading
This commit is contained in:
@@ -26,6 +26,11 @@ setup() {
|
||||
this.cxz = new Bezier(this, points.map(p => projectXZ(p)));
|
||||
this.cyz = new Bezier(this, points.map(p => projectYZ(p)));
|
||||
this.t = 0;
|
||||
setSlider(`.slide-control`, v => this.setPosition(v));
|
||||
}
|
||||
|
||||
setPosition(v) {
|
||||
this.t = v;
|
||||
}
|
||||
|
||||
draw() {
|
||||
@@ -190,24 +195,3 @@ drawVector(from, vec, length, color, label) {
|
||||
});
|
||||
text(label, from.x + txt.x, from.y + txt.y);
|
||||
}
|
||||
|
||||
onMouseMove() {
|
||||
this.t = constrain(
|
||||
map(this.cursor.x,0,this.width,-0.1, 1.1)
|
||||
,0,1
|
||||
);
|
||||
redraw();
|
||||
}
|
||||
|
||||
onKeyDown() {
|
||||
let key = this.keyboard.currentKey;
|
||||
if (key === `ArrowUp`) {
|
||||
this.t += 0.01;
|
||||
if (this.t > 1) this.t = 1;
|
||||
}
|
||||
if (key === `ArrowDown`) {
|
||||
this.t -= 0.01;
|
||||
if (this.t < 0) this.t = 0;
|
||||
}
|
||||
redraw();
|
||||
}
|
Reference in New Issue
Block a user