Skip to content

Commit f534161

Browse files
committed
Makes interpolate and polar static methods.
1 parent df74bcb commit f534161

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/easeljs/geom/Point.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,28 @@ this.createjs = this.createjs||{};
118118
* @method offset
119119
* @param {Number} The length coordinate of the polar pair.
120120
* @param {Number} The angle, in radians, of the polar pair.
121-
* @return {Point} This instance. Useful for chaining method calls.
121+
* @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
122+
* @return {Point} The new, interpolated point.
122123
* @chainable
123124
*/
124-
p.polar = function(len, angle) {
125-
this.x = len * (Math.cos(angle));
126-
this.y = len * (Math.sin(angle));
127-
return this;
125+
Point.polar = function(len, angle, pt) {
126+
pt = pt||{};
127+
pt.x = len * (Math.cos(angle));
128+
pt.y = len * (Math.sin(angle));
129+
return pt;
128130
};
129131

130132
/**
131133
* Determines a point between two specified points. The parameter `f` determines where the new interpolated point is located relative to the two end points specified by parameters `pt1` and `pt2`. The closer the value of the parameter `f` is to 1.0, the closer the interpolated point is to the first point (parameter `pt1`). The closer the value of the parameter `f` is to 0, the closer the interpolated point is to the second point (parameter `pt2`).
132134
* @method offset
133-
* @param {Point} The first point.
134-
* @param {Point} The second point.
135+
* @param {Point | Object} The first point as a Point or generic object.
136+
* @param {Point | Object} The second point as a Point or generic object.
135137
* @param {Number} The level of interpolation between the two points. Indicates where the new point will be, along the line between `pt1` and `pt2`. If `f=1`, `pt1` is returned; if `f=0`, `pt2` is returned.
136138
* @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
137139
* @return {Point} The new, interpolated point.
138140
* @chainable
139141
*/
140-
p.interpolate = function(pt1, pt2, f, pt) {
142+
Point.interpolate = function(pt1, pt2, f, pt) {
141143
pt = pt||{};
142144
pt.x = pt2.x + (f * (pt1.x - pt2.x));
143145
pt.y = pt2.y + (f * (pt1.y - pt2.y));

0 commit comments

Comments
 (0)