From 5f5f7b16844620ae6495b0664ee376baef7c58e9 Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 30 Aug 2017 14:23:03 -0400 Subject: [PATCH] add get svg function --- src/virtual-machine.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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.