Merge pull request #673 from fsih/updateRotationCenter

Update rotation center
This commit is contained in:
DD Liu 2017-09-06 17:02:08 -04:00 committed by GitHub
commit 7f6ac3de35

View file

@ -379,16 +379,15 @@ class VirtualMachine extends EventEmitter {
* Update a costume with the given SVG * Update a costume with the given SVG
* @param {int} costumeIndex - the index of the costume to be updated. * @param {int} costumeIndex - the index of the costume to be updated.
* @param {string} svg - new SVG for the renderer. * @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) { updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) {
const costume = this.editingTarget.sprite.costumes[costumeIndex]; const costume = this.editingTarget.sprite.costumes[costumeIndex];
if (costume && this.runtime && this.runtime.renderer) { if (costume && this.runtime && this.runtime.renderer) {
const rotationCenter = [ costume.rotationCenterX = rotationCenterX;
costume.rotationCenterX / costume.bitmapResolution, costume.rotationCenterY = rotationCenterY;
costume.rotationCenterY / costume.bitmapResolution this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]);
];
this.runtime.renderer.updateSVGSkin(costume.skinId, svg, rotationCenter);
} }
// @todo: Also update storage in addition to renderer. Without storage, if you switch // @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. // costumes and switch back, you will lose your changes in the paint editor.