From 89eb1ce39b25a49f22a33aeabd3cc9124fa26e9d Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 10 Apr 2018 09:51:29 -0400 Subject: [PATCH] Set the costume asset size when a costume is loaded or modified. --- src/import/load-costume.js | 2 ++ src/virtual-machine.js | 1 + 2 files changed, 3 insertions(+) diff --git a/src/import/load-costume.js b/src/import/load-costume.js index a355edddc..e94e1c917 100644 --- a/src/import/load-costume.js +++ b/src/import/load-costume.js @@ -26,6 +26,7 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) { ]; if (costumeAsset.assetType === AssetType.ImageVector) { costume.skinId = runtime.renderer.createSVGSkin(costumeAsset.decodeText(), rotationCenter); + costume.size = runtime.renderer.getSkinSize(costume.skinId); return costume; } @@ -50,6 +51,7 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) { imageElement.src = costumeAsset.encodeDataURI(); }).then(imageElement => { costume.skinId = runtime.renderer.createBitmapSkin(imageElement, costume.bitmapResolution, rotationCenter); + costume.size = runtime.renderer.getSkinSize(costume.skinId); return costume; }); }; diff --git a/src/virtual-machine.js b/src/virtual-machine.js index abe4b69ba..b9d351f8e 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -541,6 +541,7 @@ class VirtualMachine extends EventEmitter { costume.rotationCenterX = rotationCenterX; costume.rotationCenterY = rotationCenterY; this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]); + costume.size = this.runtime.renderer.getSkinSize(costume.skinId); } const storage = this.runtime.storage; costume.assetId = storage.builtinHelper.cache(