mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Simplify addJoin().
This commit is contained in:
parent
8f7deef61c
commit
a4b37a6278
1 changed files with 22 additions and 27 deletions
|
@ -1098,33 +1098,28 @@ var Path = this.Path = PathItem.extend({
|
||||||
if (join === 'round' || handleIn && handleOut) {
|
if (join === 'round' || handleIn && handleOut) {
|
||||||
bounds = bounds.unite(joinBounds.setCenter(matrix
|
bounds = bounds.unite(joinBounds.setCenter(matrix
|
||||||
? matrix.transform(segment._point) : segment._point));
|
? matrix.transform(segment._point) : segment._point));
|
||||||
} else {
|
} else if (join == 'bevel') {
|
||||||
switch (join) {
|
var curve = segment.getCurve();
|
||||||
case 'bevel':
|
addBevelJoin(curve, 0);
|
||||||
var curve = segment.getCurve();
|
addBevelJoin(curve.getPrevious(), 1);
|
||||||
addBevelJoin(curve, 0);
|
} else if (join == 'miter') {
|
||||||
addBevelJoin(curve.getPrevious(), 1);
|
var curve2 = segment.getCurve(),
|
||||||
break;
|
curve1 = curve2.getPrevious(),
|
||||||
case 'miter':
|
point = curve2.getPoint(0),
|
||||||
var curve2 = segment.getCurve(),
|
normal1 = curve1.getNormal(1).normalize(radius),
|
||||||
curve1 = curve2.getPrevious(),
|
normal2 = curve2.getNormal(0).normalize(radius),
|
||||||
point = curve2.getPoint(0),
|
// Intersect the two lines
|
||||||
normal1 = curve1.getNormal(1).normalize(radius),
|
line1 = new Line(point.add(normal1),
|
||||||
normal2 = curve2.getNormal(0).normalize(radius),
|
new Point(-normal1.y, normal1.x)),
|
||||||
// Intersect the two lines
|
line2 = new Line(point.subtract(normal2),
|
||||||
line1 = new Line(point.add(normal1),
|
new Point(-normal2.y, normal2.x)),
|
||||||
new Point(-normal1.y, normal1.x)),
|
corner = line1.intersect(line2);
|
||||||
line2 = new Line(point.subtract(normal2),
|
// Now measure the distance from the segment to the
|
||||||
new Point(-normal2.y, normal2.x)),
|
// intersection, which his half of the miter distance
|
||||||
corner = line1.intersect(line2);
|
if (!corner || point.getDistance(corner) > miter) {
|
||||||
// Now measure the distance from the segment to the
|
addJoin(segment, 'bevel');
|
||||||
// intersection, which his half of the miter distance
|
} else {
|
||||||
if (!corner || point.getDistance(corner) > miter) {
|
add(corner);
|
||||||
addJoin(segment, 'bevel');
|
|
||||||
} else {
|
|
||||||
add(corner);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue