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) { if (costumeAsset.assetType === AssetType.ImageVector) {
costume.skinId = runtime.renderer.createSVGSkin(costumeAsset.decodeText(), rotationCenter); costume.skinId = runtime.renderer.createSVGSkin(costumeAsset.decodeText(), rotationCenter);
costume.size = runtime.renderer.getSkinSize(costume.skinId);
return costume; return costume;
} }
@ -50,6 +51,7 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
imageElement.src = costumeAsset.encodeDataURI(); imageElement.src = costumeAsset.encodeDataURI();
}).then(imageElement => { }).then(imageElement => {
costume.skinId = runtime.renderer.createBitmapSkin(imageElement, costume.bitmapResolution, rotationCenter); costume.skinId = runtime.renderer.createBitmapSkin(imageElement, costume.bitmapResolution, rotationCenter);
costume.size = runtime.renderer.getSkinSize(costume.skinId);
return costume; return costume;
}); });
}; };

View file

@ -541,6 +541,7 @@ class VirtualMachine extends EventEmitter {
costume.rotationCenterX = rotationCenterX; costume.rotationCenterX = rotationCenterX;
costume.rotationCenterY = rotationCenterY; costume.rotationCenterY = rotationCenterY;
this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]); this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]);
costume.size = this.runtime.renderer.getSkinSize(costume.skinId);
} }
const storage = this.runtime.storage; const storage = this.runtime.storage;
costume.assetId = storage.builtinHelper.cache( costume.assetId = storage.builtinHelper.cache(