✨ Switch to curve.edge for finding path edge
This commit is contained in:
parent
85ec8d4afc
commit
2d0f48bfc6
3 changed files with 45 additions and 30 deletions
28
src/path.js
28
src/path.js
|
@ -7,6 +7,7 @@ import {
|
|||
curvesIntersect,
|
||||
pointOnLine,
|
||||
pointOnCurve,
|
||||
curveEdge,
|
||||
round
|
||||
} from "./utils";
|
||||
|
||||
|
@ -484,31 +485,8 @@ Path.prototype.edge = function(side) {
|
|||
else return this.rightOp.from;
|
||||
}
|
||||
} else if (this[s].type === "curve") {
|
||||
let line;
|
||||
if (side === "top")
|
||||
line = {
|
||||
p1: { x: this.topLeft.x, y: this.topLeft.y },
|
||||
p2: { x: this.bottomRight.x, y: this.topLeft.y }
|
||||
};
|
||||
else if (side === "left")
|
||||
line = {
|
||||
p1: { x: this.topLeft.x, y: this.topLeft.y },
|
||||
p2: { x: this.topLeft.x, y: this.bottomRight.y }
|
||||
};
|
||||
else if (side === "bottom")
|
||||
line = {
|
||||
p1: { x: this.topLeft.x, y: this.bottomRight.y },
|
||||
p2: { x: this.bottomRight.x, y: this.bottomRight.y }
|
||||
};
|
||||
else if (side === "right")
|
||||
line = {
|
||||
p1: { x: this.bottomRight.x, y: this.topLeft.y },
|
||||
p2: { x: this.bottomRight.x, y: this.bottomRight.y }
|
||||
};
|
||||
let bz = edgeCurveAsBezier(this[s]);
|
||||
let isect = bz.intersects(line);
|
||||
let edge = bz.get(isect[0]);
|
||||
return new Point(edge.x, edge.y);
|
||||
let curve = edgeCurveAsBezier(this[s]);
|
||||
return curveEdge(curve, side);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue