From 894c1efeeeb9da2d0d47b59093993d61cf3b8d86 Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 22 Nov 2017 22:05:18 +0000 Subject: [PATCH] fix `point` argument of Body.scale, closes #428 --- src/body/Body.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/body/Body.js b/src/body/Body.js index 39ba0d3..2048d87 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -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);