How to write the code of HTML5 Canvas sawtooth graph
This article introduces you how to write HTML5 Canvas sawtooth code, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Effect picture:
Tip: copy the code to a html file and save it, and you can see the effect by opening it directly.
Implementation code:
The code is as follows:
Sawtooth graph
Window.addEventListener ("load", eventWindowLoaded, false)
Function eventWindowLoaded () {
Var x,y
Var theCanvas = document.getElementById ("canvas")
Var context = theCanvas.getContext ("2d")
/ / Box
Context.strokeStyle ='# 00f'
Context.lineWidth=10
Context.strokeRect (0,0, theCanvas.width-0, theCanvas.height-0)
Context.fillStyle = "# 00f"
For (Xerox)