@scotty_walker
To set a default image to a canvas, you can follow these steps:
1
|
<canvas id="myCanvas" width="300" height="150"></canvas> |
1 2 3 4 5 6 7 8 9 10 11 |
function drawDefaultImage() {
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
var img = new Image();
img.src = 'default-image.jpg';
img.onload = function() {
ctx.drawImage(img, 0, 0);
};
}
|
1 2 3 |
window.onload = function() {
drawDefaultImage();
}
|
By following these steps, the default image will be displayed on the canvas when the page loads.