mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Simplify Path#arcTo().
This commit is contained in:
parent
a4b37a6278
commit
a3065a59d1
1 changed files with 13 additions and 15 deletions
|
@ -840,25 +840,24 @@ var Path = this.Path = PathItem.extend({
|
|||
var relx = Math.cos(angle),
|
||||
rely = Math.sin(angle),
|
||||
pt = new Point(
|
||||
centerX + relx * radius,
|
||||
centerY + rely * radius);
|
||||
var out;
|
||||
if (i == arcSegs) {
|
||||
out = null;
|
||||
} else {
|
||||
out = new Point(
|
||||
centerX + (relx - z * rely) * radius - pt.x,
|
||||
centerY + (rely + z * relx) * radius - pt.y);
|
||||
}
|
||||
centerX + relx * radius,
|
||||
centerY + rely * radius
|
||||
);
|
||||
var out = i == arcSegs
|
||||
? null
|
||||
: new Point(
|
||||
centerX + (relx - z * rely) * radius - pt.x,
|
||||
centerY + (rely + z * relx) * radius - pt.y
|
||||
);
|
||||
if (i == 0) {
|
||||
// Modify startSegment
|
||||
current.setHandleOut(out);
|
||||
} else {
|
||||
// Add new Segment
|
||||
var handleIn = new Point(
|
||||
centerX + (relx + z * rely) * radius - pt.x,
|
||||
centerY + (rely - z * relx) * radius - pt.y);
|
||||
segments.push(new Segment(pt, handleIn, out));
|
||||
segments.push(new Segment(pt, new Point(
|
||||
centerX + (relx + z * rely) * radius - pt.x,
|
||||
centerY + (rely - z * relx) * radius - pt.y
|
||||
), out));
|
||||
}
|
||||
angle += inc;
|
||||
}
|
||||
|
@ -1073,7 +1072,6 @@ var Path = this.Path = PathItem.extend({
|
|||
// It seems to be compatible with Ai we need to pass pen padding
|
||||
// untransformed to getBounds()
|
||||
bounds = getBounds(this, matrix, getPenPadding(radius));
|
||||
|
||||
// Create a rectangle of padding size, used for union with bounds
|
||||
// further down
|
||||
var joinBounds = new Rectangle(new Size(padding).multiply(2));
|
||||
|
|
Loading…
Reference in a new issue