简体   繁体   English

如何在Opera中清除Canvas?

[英]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. 我有以下代码,它似乎在Chrome中工作正常,但在Opera中不起作用。 Here is the code: 这是代码:

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

var context = canvas.getContext("2d"); var context = canvas.getContext(“2d”); canvas.width = canvas.width; 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. 使用上面的代码在绘制后清除线条,它在Chrome中工作正常,但在Opera中,绘图没有被清除。 Please help. 请帮忙。 Thank you so much. 非常感谢。

Use clearRect(); 使用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. 如果提供整个画布的尺寸,则必须完全重绘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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