简体   繁体   中英

How to clear Canvas in Opera?

Could someone please help me? I have the following code and it seems to work fine in Chrome, but does not work in Opera. Here is the code:

 var canvas = document.getElementById("myCanvas");

var context = canvas.getContext("2d"); canvas.width = canvas.width;

Using above code to clear the line after drawing, it works fine in Chrome, but in Opera it the drawing did not get cleared. Please help. Thank you so much.

Use clearRect(); This is th only method I know which clears the canvas

clear the expected area you want or provide height and width of entire canvas. If you provide the dimensions of entire canvas you will have to redraw it completely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM