<canvas> is a new tag in HTML5, which is used to draw graphics. This article is mainly for everyone This article introduces the basic drawing method of drawing line segments in HTML5 canvas in detail. Interested friends can refer to it
is HTML5 The newly added tag is used to draw graphics. In fact, this tag is the same as other tags. Its special feature is that this tag can obtain a CanvasRenderingContext2D object. We can use JavaScriptScript to control the object for drawing.
is just a container for drawing graphics. In addition to id, class, style and other attributes, There are also height and width properties. There are three main steps for drawing on the
1. Get the
DOM object corresponding to the 2. Call the getContext() method of the Canvas object to get a CanvasRenderingContext2D object;
3. Call the CanvasRenderingContext2D object for drawing.
Draw line segments moveTo() and lineTo()
The following is a simple