I need to change background image in HTML5 canvas.
I want to use 2 different thumbnails as buttons and when I click on one of the images the background should be change to that particular image.
I need to change background image in HTML5 canvas.
I want to use 2 different thumbnails as buttons and when I click on one of the images the background should be change to that particular image.
click
of the appropriate buttons set a unique CSS class on your <canvas>
element.Drawing commands and erasing your canvas will not affect the CSS-applied background image behind your content.
redraw()
function that knows how to erase the canvas and regenerate your drawing, including determining what image to draw as the background first.click
of the buttons set a variable and re-invoke your redraw()
function. It will erase your canvas and use the variable to draw the correct image.