1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-25 17:42:46 +02:00

curve/curve intersection

This commit is contained in:
Pomax
2020-08-29 12:49:23 -07:00
parent bdc7c4228d
commit f4eafa288a
10 changed files with 235 additions and 163 deletions

View File

@@ -123,15 +123,29 @@ class GraphicsAPI extends BaseAPI {
this.currentPoint = false;
}
resetMovable(points) {
resetMovable(...allpoints) {
this.movable.splice(0, this.movable.length);
if (points) this.setMovable(points);
if (allpoints) this.setMovable(...allpoints);
}
setMovable(...allpoints) {
allpoints.forEach((points) => points.forEach((p) => this.movable.push(p)));
}
/**
* Multi-panel graphics: set panel count
*/
setPanelCount(c) {
this.panelWidth = this.width / c;
}
/**
* Multi-panel graphics: set up (0,0) to the next panel's start
*/
nextPanel(c) {
this.translate(this.panelWidth, 0);
}
/**
* Set up a slider to control a named, numerical property in the sketch.
*
@@ -156,11 +170,13 @@ class GraphicsAPI extends BaseAPI {
slider.value = initial;
this[propname] = parseFloat(slider.value);
let handlerName = `on${propname[0].toUpperCase()}${propname
.substring(1)
.toLowerCase()}`;
slider.listen(`input`, (evt) => {
this[propname] = parseFloat(evt.target.value);
if (redraw && !this.redrawing) {
this.redraw();
}
if (this[handlerName]) this[handlerName](this[propname]);
if (redraw && !this.redrawing) this.redraw();
});
return slider;

View File

@@ -177,6 +177,20 @@ class Bezier extends Original {
}
ctx.restoreStyle();
}
drawBoundingBox(color) {
let bbox = this.bbox(),
mx = bbox.x.min,
my = bbox.y.min,
MX = bbox.x.max,
MY = bbox.y.max,
api = this.api;
api.cacheStyle();
api.noFill();
api.setStroke(color ? color : `black`);
api.rect(mx, my, MX - mx, MY - my);
api.restoreStyle();
}
}
export { Bezier };

View File

@@ -805,7 +805,7 @@ const utils = {
];
}
const cc1 = c1.split(0.5),
let cc1 = c1.split(0.5),
cc2 = c2.split(0.5),
pairs = [
{ left: cc1.left, right: cc2.left },
@@ -818,7 +818,7 @@ const utils = {
return utils.bboxoverlap(pair.left.bbox(), pair.right.bbox());
});
const results = [];
let results = [];
if (pairs.length === 0) return results;