javascript - canvas clearRect failed to clear
黄舟
黄舟 2017-05-31 10:40:24
0
3
1043


As shown in the figure, it is not compatible with some Android machines. The effect will be that when the number changes from 1 to 35, 1 is not deleted and overlaps with 35. , how should this problem be solved?
The demo address is as follows:
https://chengzhuotc.github.io...

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
伊谢尔伦

Add cts.save() in front of moveTo;
Try adding cts.restore() after fillText;

Ty80

You need to check whether the range of clearRect exceeds the size of the canvas. If it does, there will be some inexplicable bugs.

Ty80

Because canvas drawing can overlap.
You can refer to this blog:
http://www.jianshu.com/p/2d51...
In this blog, clearRect() is used to clear the original rectangle before each drawing. You can do it similarly in Before each drawing of text, clear the original text.
But after I checked the canvas API, I found that there is no corresponding clear method for filltext(), or maybe I didn’t find it.
So I suggest you try it:
Draw an " " empty string before each drawing, that is,
add cts.fillText(" before cts.fillText(process+"%",x,y) "+"%",x,y)Overwrite the previously written words and rewrite them.
Hope it helps you~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template