1
0
Fork 0

Switch to curve.edge for finding path edge

This commit is contained in:
Joost De Cock 2018-09-03 12:07:02 +02:00
parent 85ec8d4afc
commit 2d0f48bfc6
3 changed files with 45 additions and 30 deletions

View file

@ -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);
}
}
};