From 267395b13b4bda5b9ac0d9589d6263945873c9a9 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Wed, 26 Feb 2020 16:22:32 -0500 Subject: [PATCH] Remove remaining updateDrawableProperties calls --- src/blocks/scratch3_looks.js | 36 +++++++++++++--------------- src/extensions/scratch3_pen/index.js | 2 +- src/io/video.js | 20 +++++++--------- test/fixtures/fake-renderer.js | 4 ---- 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index a6da97f35..a5daf7a0c 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -178,23 +178,21 @@ class Scratch3LooksBlocks { bubbleState.onSpriteRight = true; this._renderBubble(target); } else { - this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, { - position: [ - bubbleState.onSpriteRight ? ( - Math.max( - stageBounds.left, // Bubble should not extend past left edge of stage - Math.min(stageBounds.right - bubbleWidth, targetBounds.right) - ) - ) : ( - Math.min( - stageBounds.right - bubbleWidth, // Bubble should not extend past right edge of stage - Math.max(stageBounds.left, targetBounds.left - bubbleWidth) - ) - ), - // Bubble should not extend past the top of the stage - Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight) - ] - }); + this.runtime.renderer.updateDrawablePosition(bubbleState.drawableId, [ + bubbleState.onSpriteRight ? ( + Math.max( + stageBounds.left, // Bubble should not extend past left edge of stage + Math.min(stageBounds.right - bubbleWidth, targetBounds.right) + ) + ) : ( + Math.min( + stageBounds.right - bubbleWidth, // Bubble should not extend past right edge of stage + Math.max(stageBounds.left, targetBounds.left - bubbleWidth) + ) + ), + // Bubble should not extend past the top of the stage + Math.min(stageBounds.top, targetBounds.bottom + bubbleHeight) + ]); this.runtime.requestRedraw(); } } @@ -225,9 +223,7 @@ class Scratch3LooksBlocks { target.addListener(RenderedTarget.EVENT_TARGET_VISUAL_CHANGE, this._onTargetChanged); bubbleState.drawableId = this.runtime.renderer.createDrawable(StageLayering.SPRITE_LAYER); bubbleState.skinId = this.runtime.renderer.createTextSkin(type, text, bubbleState.onSpriteRight, [0, 0]); - this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, { - skinId: bubbleState.skinId - }); + this.runtime.renderer.updateDrawableSkinId(bubbleState.drawableId, bubbleState.skinId); } this._positionBubble(target); diff --git a/src/extensions/scratch3_pen/index.js b/src/extensions/scratch3_pen/index.js index 78705a5f5..a1f5b4460 100644 --- a/src/extensions/scratch3_pen/index.js +++ b/src/extensions/scratch3_pen/index.js @@ -132,7 +132,7 @@ class Scratch3PenBlocks { if (this._penSkinId < 0 && this.runtime.renderer) { this._penSkinId = this.runtime.renderer.createPenSkin(); this._penDrawableId = this.runtime.renderer.createDrawable(StageLayering.PEN_LAYER); - this.runtime.renderer.updateDrawableProperties(this._penDrawableId, {skinId: this._penSkinId}); + this.runtime.renderer.updateDrawableSkinId(this._penDrawableId, this._penSkinId); } return this._penSkinId; } diff --git a/src/io/video.js b/src/io/video.js index f037b0f9c..23dce8b79 100644 --- a/src/io/video.js +++ b/src/io/video.js @@ -128,16 +128,18 @@ class Video { this._ghost = ghost; // Confirm that the default value has been changed to a valid id for the drawable if (this._drawable !== -1) { - this.runtime.renderer.updateDrawableProperties(this._drawable, { - ghost: this._forceTransparentPreview ? 100 : ghost - }); + this.runtime.renderer.updateDrawableEffect( + this._drawable, + 'ghost', + this._forceTransparentPreview ? 100 : ghost + ); } } _disablePreview () { if (this._skinId !== -1) { this.runtime.renderer.updateBitmapSkin(this._skinId, new ImageData(...Video.DIMENSIONS), 1); - this.runtime.renderer.updateDrawableProperties(this._drawable, {visible: false}); + this.runtime.renderer.updateDrawableVisible(this._drawable, false); } this._renderPreviewFrame = null; } @@ -149,17 +151,13 @@ class Video { if (this._skinId === -1 && this._drawable === -1) { this._skinId = renderer.createBitmapSkin(new ImageData(...Video.DIMENSIONS), 1); this._drawable = renderer.createDrawable(StageLayering.VIDEO_LAYER); - renderer.updateDrawableProperties(this._drawable, { - skinId: this._skinId - }); + renderer.updateDrawableSkinId(this._drawable, this._skinId); } // if we haven't already created and started a preview frame render loop, do so if (!this._renderPreviewFrame) { - renderer.updateDrawableProperties(this._drawable, { - ghost: this._forceTransparentPreview ? 100 : this._ghost, - visible: true - }); + renderer.updateDrawableEffect(this._drawable, 'ghost', this._forceTransparentPreview ? 100 : this._ghost); + renderer.updateDrawableVisible(this._drawable, true); this._renderPreviewFrame = () => { clearTimeout(this._renderPreviewTimeout); diff --git a/test/fixtures/fake-renderer.js b/test/fixtures/fake-renderer.js index 73b37ede6..c89f8801f 100644 --- a/test/fixtures/fake-renderer.js +++ b/test/fixtures/fake-renderer.js @@ -34,10 +34,6 @@ FakeRenderer.prototype.updateDrawableVisible = function (d, visible) { // eslint FakeRenderer.prototype.updateDrawableEffect = function (d, effectName, value) { // eslint-disable-line no-unused-vars }; -FakeRenderer.prototype.updateDrawableProperties = function (d, p) { // eslint-disable-line no-unused-vars - throw new Error('updateDrawableProperties is deprecated'); -}; - FakeRenderer.prototype.getCurrentSkinSize = function (d) { // eslint-disable-line no-unused-vars return [0, 0]; };