Change background image in HTML5 canvas

I need to change the 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 needs to be changed to that particular image.

0
source share
1 answer

Technique 1

  • In the clickcorresponding buttons, set a unique CSS class in your <canvas>element.
  • Use CSS to apply a background image to your canvas.

Commands for drawing and erasing your canvas will not affect the background image overlaid with CSS behind your content.

Technique 2

  • redraw(), , , .
  • click redraw(). .
0

All Articles