Skip to content

Commit df74bcb

Browse files
committed
Make the return of interpolate an optional copied point.
1 parent 323edeb commit df74bcb

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/easeljs/geom/Point.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ this.createjs = this.createjs||{};
133133
* @param {Point} The first point.
134134
* @param {Point} The second point.
135135
* @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.
136-
* @return {Point} This instance. Useful for chaining method calls.
136+
* @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
137+
* @return {Point} The new, interpolated point.
137138
* @chainable
138139
*/
139-
p.interpolate = function(pt1, pt2, f) {
140-
this.x = pt2.x + (f * (pt1.x - pt2.x));
141-
this.y = pt2.y + (f * (pt1.y - pt2.y));
142-
return this;
140+
p.interpolate = function(pt1, pt2, f, pt) {
141+
pt = pt||{};
142+
pt.x = pt2.x + (f * (pt1.x - pt2.x));
143+
pt.y = pt2.y + (f * (pt1.y - pt2.y));
144+
return pt;
143145
};
144146

145147
/**

0 commit comments

Comments
 (0)