Set the costume asset size when a costume is loaded or modified.

This commit is contained in:
Paul Kaplan 2018-04-10 09:51:29 -04:00
parent f29482957c
commit 89eb1ce39b
2 changed files with 3 additions and 0 deletions

View file

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

View file

@ -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(