add get svg function

This commit is contained in:
DD 2017-08-30 14:23:03 -04:00
parent fc4f073526
commit 5f5f7b1684

View file

@ -340,6 +340,20 @@ class VirtualMachine extends EventEmitter {
return null; return null;
} }
/**
* Get an SVG string from the renderer.
* @param {int} costumeIndex - the index of the sound to be got.
* @return {string} the costume's SVG string, or null if it's not an SVG costume.
*/
getCostumeSVG (costumeIndex) {
const id = this.editingTarget.sprite.costumes[costumeIndex].assetId;
if (id && this.runtime && this.runtime.storage &&
this.runtime.storage.get(id).dataFormat === 'svg') {
return this.runtime.storage.get(id).decodeText();
}
return null;
}
/** /**
* Update a sound buffer. * Update a sound buffer.
* @param {int} soundIndex - the index of the sound to be updated. * @param {int} soundIndex - the index of the sound to be updated.