mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-25 17:42:46 +02:00
figured out how to reuse sketches with data-attribute parameters
This commit is contained in:
@@ -100,7 +100,6 @@ class BaseAPI {
|
||||
// of its own mouseMove handling.
|
||||
if (this.movable.length && this.currentPoint && !this.redrawing) {
|
||||
this.redraw();
|
||||
this.redrawing = false;
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -256,6 +255,7 @@ class BaseAPI {
|
||||
redraw() {
|
||||
this.redrawing = true;
|
||||
this.draw();
|
||||
this.redrawing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -157,7 +157,7 @@ class GraphicsAPI extends BaseAPI {
|
||||
* @param {String} local query selector for the type=range element.
|
||||
* @param {String} propname the name of the property to control.
|
||||
* @param {float} initial the initial value for this property.
|
||||
* @param {boolean} redraw whether or not to redraw after update the value from the slider.
|
||||
* @param {boolean} redraw whether or not to redraw after updating the value from the slider.
|
||||
*/
|
||||
setSlider(qs, propname, initial, redraw = true) {
|
||||
if (typeof this[propname] !== `undefined`) {
|
||||
@@ -177,7 +177,9 @@ class GraphicsAPI extends BaseAPI {
|
||||
|
||||
slider.listen(`input`, (evt) => {
|
||||
this[propname] = parseFloat(evt.target.value);
|
||||
if (redraw) this.redraw();
|
||||
if (redraw && !this.redrawing) {
|
||||
this.redraw();
|
||||
}
|
||||
});
|
||||
|
||||
return slider;
|
||||
@@ -711,6 +713,12 @@ class GraphicsAPI extends BaseAPI {
|
||||
constrain(v, s, e) {
|
||||
return v < s ? s : v > e ? e : v;
|
||||
}
|
||||
|
||||
dist(x1, y1, x2, y2) {
|
||||
let dx = x1 - x2;
|
||||
let dy = y1 - y2;
|
||||
return this.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
||||
export { GraphicsAPI, Bezier, Vector, Matrix, Shape };
|
||||
|
Reference in New Issue
Block a user