From 29540e705e2a42674fd2d8a6be080e3115c820c5 Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 5 Sep 2017 16:51:03 -0400 Subject: [PATCH 1/3] Add updating the rotation center to updateSvg --- src/virtual-machine.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 61afda386..04409b3b0 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -380,15 +380,12 @@ class VirtualMachine extends EventEmitter { * @param {int} costumeIndex - the index of the costume to be updated. * @param {string} svg - new SVG for the renderer. */ - updateSvg (costumeIndex, svg) { + updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) { const costume = this.editingTarget.sprite.costumes[costumeIndex]; + costume.rotationCenterX = rotationCenterX; + costume.rotationCenterY = rotationCenterY; if (costume && this.runtime && this.runtime.renderer) { - const rotationCenter = [ - costume.rotationCenterX / costume.bitmapResolution, - costume.rotationCenterY / costume.bitmapResolution - ]; - - this.runtime.renderer.updateSVGSkin(costume.skinId, svg, rotationCenter); + this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]); } // @todo: Also update storage in addition to renderer. Without storage, if you switch // costumes and switch back, you will lose your changes in the paint editor. From 48fec12391126d1e535d8a4bb8813a1652820a73 Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 5 Sep 2017 17:49:30 -0400 Subject: [PATCH 2/3] add jsdoc --- src/virtual-machine.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 04409b3b0..45a2de167 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -379,6 +379,8 @@ class VirtualMachine extends EventEmitter { * Update a costume with the given SVG * @param {int} costumeIndex - the index of the costume to be updated. * @param {string} svg - new SVG for the renderer. + * @param {number} rotationCenterX x of point about which the costume rotates, relative to its upper left corner + * @param {number} rotationCenterY y of point about which the costume rotates, relative to its upper left corner */ updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) { const costume = this.editingTarget.sprite.costumes[costumeIndex]; From caf98cb185e876737afd0cc09fd23781e7c804ef Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 5 Sep 2017 17:53:27 -0400 Subject: [PATCH 3/3] change order --- src/virtual-machine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 45a2de167..6e16ef90a 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -384,9 +384,9 @@ class VirtualMachine extends EventEmitter { */ updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) { const costume = this.editingTarget.sprite.costumes[costumeIndex]; - costume.rotationCenterX = rotationCenterX; - costume.rotationCenterY = rotationCenterY; if (costume && this.runtime && this.runtime.renderer) { + costume.rotationCenterX = rotationCenterX; + costume.rotationCenterY = rotationCenterY; this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]); } // @todo: Also update storage in addition to renderer. Without storage, if you switch