Skip to content

Commit

Permalink
ghjh
Browse files Browse the repository at this point in the history
  • Loading branch information
loglot authored Sep 1, 2023
1 parent 8e8ad10 commit 475d82b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,26 @@ var scaleY = 0;
const desiredWidth = desiredHeight / aspectRatio;
canvas.width = desiredWidth;
canvas.height = desiredHeight;
scaleX = (desiredWidth / originalWidth);
scaleY = (desiredHeight / originalHeight);
ctx.setTransform(scaleY, 0, 0, scaleX, 0, 0)
}else {
const desiredWidth = windowWidth;
const aspectRatio = originalWidth / originalHeight;
const desiredHeight = desiredWidth / aspectRatio;
canvas.width = desiredWidth;
canvas.height = desiredHeight;
scaleX = (desiredWidth / originalWidth);
scaleY = (desiredHeight / originalHeight);
ctx.setTransform(scaleY, 0, 0, scaleX, 0, 0)
}


// Set the canvas element's width and height


// Resize the canvas drawing area to maintain the aspect ratio
scaleX = (desiredWidth / originalWidth);
scaleY = (desiredHeight / originalHeight);

// Apply the scaling transformation to maintain the aspect ratio
ctx.setTransform(scaleY, 0, 0, scaleX, 0, 0)

}

0 comments on commit 475d82b

Please sign in to comment.