src/virtual-machine.js
/**
     * Update a costume with the given SVG
     * @param {int} costumeIndex - the index of the costume to be updated.
     * @param {string} svg - new SVG for the renderer.
     * @param {number} rotationCenterX x of point about which the costume rotates, relative to its upper left corner
     * @param {number} rotationCenterY y of point about which the costume rotates, relative to its upper left corner
     */
Update a costume with the given SVG
@param {int} costumeIndex - the index of the costume to be updated.
@param {string} svg - new SVG for the renderer.
@param {number} rotationCenterX x of point about which the costume rotates, relative to its upper left corner
@param {number} rotationCenterY y of point about which the costume rotates, relative to its upper left corner
Update a costume with the given SVG @param { int } costumeIndex - the index of the costume to be updated . @param { string } svg - new SVG for the renderer . @param { number } rotationCenterX x of point about which the costume rotates relative to its upper left corner @param { number } rotationCenterY y of point about which the costume rotates relative to its upper left corner
updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) {
        const costume = this.editingTarget.getCostumes()[costumeIndex];
        if (costume && this.runtime && this.runtime.renderer) {
            costume.rotationCenterX = rotationCenterX;
            costume.rotationCenterY = rotationCenterY;
            this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]);
        }
        const storage = this.runtime.storage;
        costume.assetId = storage.builtinHelper.cache(
            storage.AssetType.ImageVector,
            storage.DataFormat.SVG,
            (new TextEncoder()).encode(svg)
        );
        costume.dataFormat = storage.DataFormat.SVG;
        costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
        this.emitTargetsUpdate();
    }
updateSvg ( costumeIndex , svg , rotationCenterX , rotationCenterY ) { const costume = this . editingTarget . getCostumes ( ) [ costumeIndex ] ; if ( costume && this . runtime && this . runtime . renderer ) { costume . rotationCenterX = rotationCenterX ; costume . rotationCenterY = rotationCenterY ; this . runtime . renderer . updateSVGSkin ( costume . skinId , svg , [ rotationCenterX , rotationCenterY ] ) ; } const storage = this . runtime . storage ; costume . assetId = storage . builtinHelper . cache ( storage . AssetType . ImageVector , storage . DataFormat . SVG , ( new TextEncoder ( ) ) . encode ( svg ) ) ; costume . dataFormat = storage . DataFormat . SVG ; costume . md5 = ` ${ costume . assetId } ${ costume . dataFormat } ` ; this . emitTargetsUpdate ( ) ; }
Update a costume with the given SVG
 @param {int} costumeIndex - the index of the costume to be updated.
Update a costume with the given SVG @param { int } costumeIndex - the index of the costume to be updated .
// If we're in here, we've edited an svg in the vector editor, // so the dataFormat should be 'svg'