mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-06-25 22:41:45 -04:00
Merge pull request #588 from adroitwhiz/fix-resize
Call draw() after resizing canvas
This commit is contained in:
commit
b6424a2f80
1 changed files with 17 additions and 2 deletions
|
@ -220,9 +220,20 @@ class RenderWebGL extends EventEmitter {
|
|||
* @param {int} pixelsTall The desired height in device-independent pixels.
|
||||
*/
|
||||
resize (pixelsWide, pixelsTall) {
|
||||
const {canvas} = this._gl;
|
||||
const pixelRatio = window.devicePixelRatio || 1;
|
||||
this._gl.canvas.width = pixelsWide * pixelRatio;
|
||||
this._gl.canvas.height = pixelsTall * pixelRatio;
|
||||
const newWidth = pixelsWide * pixelRatio;
|
||||
const newHeight = pixelsTall * pixelRatio;
|
||||
|
||||
// Certain operations, such as moving the color picker, call `resize` once per frame, even though the canvas
|
||||
// size doesn't change. To avoid unnecessary canvas updates, check that we *really* need to resize the canvas.
|
||||
if (canvas.width !== newWidth || canvas.height !== newHeight) {
|
||||
canvas.width = newWidth;
|
||||
canvas.height = newHeight;
|
||||
// Resizing the canvas causes it to be cleared, so redraw it.
|
||||
this.draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1762,6 +1773,10 @@ class RenderWebGL extends EventEmitter {
|
|||
*/
|
||||
_getConvexHullPointsForDrawable (drawableID) {
|
||||
const drawable = this._allDrawables[drawableID];
|
||||
|
||||
drawable.updateMatrix();
|
||||
drawable.skin.updateSilhouette(this._getDrawableScreenSpaceScale(drawable));
|
||||
|
||||
const [width, height] = drawable.skin.size;
|
||||
// No points in the hull if invisible or size is 0.
|
||||
if (!drawable.getVisible() || width === 0 || height === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue