From dc410b6894d1cd602655c081f4ee8247dae9907e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 21 Feb 2011 00:28:13 +0100 Subject: [PATCH] Merge rotateAround() and rotate(). --- src/basic/Point.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index 92165988..6c3f8810 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -188,20 +188,17 @@ var Point = Base.extend({ } }, - rotate: function(angle) { + // TODO: Add center parameter support back to Scriptographer + rotate: function(angle, center) { + var point = center ? this.subtract(center) : this; angle = angle * Math.PI / 180; var s = Math.sin(angle); var c = Math.cos(angle); - return Point.create( - this.x * c - this.y * s, - this.y * c + this.x * s + point = Point.create( + point.x * c - point.y * s, + point.y * c + point.x * s ); - }, - - // TODO: Shouldn't center just be the optional 2nd argument to rotate()? - rotateAround: function(angle, center) { - center = new Point(center); - return this.subtract(center).rotate(angle).add(this); + return center ? point.add(center) : point; }, interpolate: function(point, t) {