Summarize the following three ways to clear Canvas canvas:
1. The easiest way: Because the content of the canvas will be emptied whenever the height or width is reused, the following methods can be used:
Function Clearcanvas <span style = FONT-FAMILY: Verdana, Arial, Songti;> () </span> {var C = DOCUMENT.GetelementByid (MyCanvas); VAR CXT = C.GetContext (2D); C.Height = C. height;}2. Use the Clearrect method:
Function Clearcanvas () {var C = Document.GetelementByid (mycanvas); Var CXT = C.GetContext (2D); CXT.CLEARRECT (0,0, C.HEIGHT);}3. Similar to Method 2, you can fill the canvas with a specific color to achieve the purpose of clearing:
Function Clearcanvas () {var C = Document.GetelementByid (mycanvas); var cxt = c.GetContext (2D); cxt.FillStyle =#000000; cxt.fillrere CT (0,0, C.Width, c.Height); CXT.CLOSEPATH ();}The above is all the contents of this article. I hope it will be helpful to everyone's learning. I also hope that everyone will support VEVB Wulin.com.