mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Set the costume asset size when a costume is loaded or modified.
This commit is contained in:
parent
f29482957c
commit
89eb1ce39b
2 changed files with 3 additions and 0 deletions
|
@ -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;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in a new issue