0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

fix point argument of Body.scale, closes #428

This commit is contained in:
liabru 2017-11-22 22:05:18 +00:00
parent 3bceef4f7e
commit 894c1efeee

View file

@ -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);