From a3065a59d1f0d47a55b2d99fe6b67c59d904dcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 6 May 2011 00:42:10 +0100 Subject: [PATCH] Simplify Path#arcTo(). --- src/path/Path.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index 463239e0..75f851f1 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -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));