Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/BitmapSkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ class BitmapSkin extends Skin {
return this._texture;
}

/**
* Get the bounds of the drawable for determining its fenced position.
* @param {Array<number>} drawable - The Drawable instance this skin is using.
* @return {!Rectangle} The drawable's bounds. For compatibility with Scratch 2, we always use getAABB for bitmaps.
*/
getFenceBounds (drawable) {
return drawable.getAABB();
}

/**
* Set the contents of this skin to a snapshot of the provided bitmap data.
* @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmapData - new contents for this skin.
Expand Down
2 changes: 1 addition & 1 deletion src/RenderWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ class RenderWebGL extends EventEmitter {

const dx = x - drawable._position[0];
const dy = y - drawable._position[1];
const aabb = drawable.getFastBounds();
const aabb = drawable._skin.getFenceBounds(drawable);
const inset = Math.floor(Math.min(aabb.width, aabb.height) / 2);

const sx = this._xRight - Math.min(FENCE_WIDTH, inset);
Expand Down
9 changes: 9 additions & 0 deletions src/Skin.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ class Skin extends EventEmitter {
return null;
}

/**
* Get the bounds of the drawable for determining its fenced position.
* @param {Array<number>} drawable - The Drawable instance this skin is using.
* @return {!Rectangle} The drawable's bounds.
*/
getFenceBounds (drawable) {
return drawable.getFastBounds();
}

/**
* Update and returns the uniforms for this skin.
* @param {Array<number>} scale - The scaling factors to be used.
Expand Down
Binary file modified test/integration/scratch-tests/sprite-goes-off-stage.sb2
Binary file not shown.