From 52041313616e48a053d673a36d7714a9dd55fa32 Mon Sep 17 00:00:00 2001 From: Zutatensuppe Date: Fri, 16 Apr 2021 01:52:34 +0200 Subject: [PATCH] fix stretched puzzle --- game/Graphics.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/game/Graphics.js b/game/Graphics.js index 9b38e65..1de3863 100644 --- a/game/Graphics.js +++ b/game/Graphics.js @@ -6,12 +6,13 @@ function createCanvas(width = 0, height = 0) { } async function loadImageToBitmap(imagePath) { - const img = new Image() - await new Promise((resolve) => { - img.onload = resolve + return new Promise((resolve) => { + const img = new Image() + img.onload = () => { + createImageBitmap(img).then(resolve) + } img.src = imagePath - }); - return await createImageBitmap(img, 0, 0, img.width, img.height) + }) } async function resizeBitmap (bitmap, width, height) {