mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #673 from fsih/updateRotationCenter
Update rotation center
This commit is contained in:
commit
7f6ac3de35
1 changed files with 6 additions and 7 deletions
|
@ -379,16 +379,15 @@ 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) {
|
||||
updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) {
|
||||
const costume = this.editingTarget.sprite.costumes[costumeIndex];
|
||||
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);
|
||||
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
|
||||
// costumes and switch back, you will lose your changes in the paint editor.
|
||||
|
|
Loading…
Reference in a new issue