Skip to content

Commit

Permalink
fix point argument of Body.scale, closes #428
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 22, 2017
1 parent 3bceef4 commit 894c1ef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/body/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,17 @@ var Axes = require('../geometry/Axes');
* @param {vector} [point]
*/
Body.scale = function(body, scaleX, scaleY, point) {
point = point || body.position;

for (var i = 0; i < body.parts.length; i++) {
var part = body.parts[i];

// scale position
part.position.x = point.x + (part.position.x - point.x) * scaleX;
part.position.y = point.y + (part.position.y - point.y) * scaleY;

// scale vertices
Vertices.scale(part.vertices, scaleX, scaleY, body.position);
Vertices.scale(part.vertices, scaleX, scaleY, point);

// update properties
part.axes = Axes.fromVertices(part.vertices);
Expand Down

0 comments on commit 894c1ef

Please sign in to comment.