diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 762ef8c01..07ce65e10 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -340,6 +340,20 @@ class VirtualMachine extends EventEmitter { 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. * @param {int} soundIndex - the index of the sound to be updated.