How to apply Canvas coordinates and paths
This article mainly explains "how to apply Canvas coordinates and paths". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Canvas coordinates and paths.
Canvas coordinates
Canvas is a two-dimensional grid.
The coordinate of the upper-left corner of canvas is (0pm 0).
The above fillRect method has parameters (0re0rec 15015015075).
Draw the rectangle of 150x75 on the canvas, starting at the upper left corner (0jin0).
Canvas- path
To draw lines on Canvas, we will use the following two methods:
MoveTo (xPowery) defines the line start coordinates
LineTo (xPowery) defines the line end coordinates
We must use the method of "ink" to draw lines, just like stroke ().
Example
Define the start coordinates (0J0) and the end coordinates (200100). Then use the stroke () method to draw the line:
_ JavaScript:
Varc=document.getElementById ("myCanvas")
Varctx=c.getContext ("2d")
Ctx.moveTo (0Pol 0)
Ctx.lineTo (200100)
Ctx.stroke ()
At this point, I believe you have a deeper understanding of "how to apply Canvas coordinates and paths". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!