mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Merge rotateAround() and rotate().
This commit is contained in:
parent
2ebe4a18da
commit
dc410b6894
1 changed files with 7 additions and 10 deletions
|
@ -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;
|
angle = angle * Math.PI / 180;
|
||||||
var s = Math.sin(angle);
|
var s = Math.sin(angle);
|
||||||
var c = Math.cos(angle);
|
var c = Math.cos(angle);
|
||||||
return Point.create(
|
point = Point.create(
|
||||||
this.x * c - this.y * s,
|
point.x * c - point.y * s,
|
||||||
this.y * c + this.x * s
|
point.y * c + point.x * s
|
||||||
);
|
);
|
||||||
},
|
return center ? point.add(center) : point;
|
||||||
|
|
||||||
// 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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
interpolate: function(point, t) {
|
interpolate: function(point, t) {
|
||||||
|
|
Loading…
Reference in a new issue