I need assistance with my code. I'm trying to draw an image on the canvas while maintaining its quality.
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");
canvas.width = 360px;
canvas.height = 360px;
const img = new Image();
img.src = "some-image.jpg"; // image dimensions are 3840*2594px
var scale = Math.min(
canvas.width / img.width,
canvas.height / img.height
);
// determine top left coordinates of the image
var x = canvas.width / 2 - (img.width / 2) * scale;
var y = canvas.height / 2 - (img.height / 2) * scale;
context.drawImage(img, x, y, img.width * scale, img.height * scale);