how to drawImage on center of canvas 1

how to drawImage on center of canvas

const img = new Image();
canvasContent.drawImage(img,
        canvas.width/2 - img.width/2,
        canvas.height/2 - img.height/2
);

Here is what the above code is Doing:
1. Create a new Image object.
2. Set the src property to the URL of the image you want to load.
3. Add an event listener for the load event.
4. Draw the image to the canvas.

Similar Posts