var ctx = cnv.getContext("2d")
And use that context to draw everything using the standard functions:
moveTo, lineTo, arc, fillRect, etc.
Learn more about drawing here.
You can use the functions to create more complicated shapes easily thanks to transform functions:
Transformations: Linear Algebra Made Easy
The origin(0,0) of the canvas is defined to be the top-left pixel of the canvas element. And the coordinates are given in number of pixels. This can change by using transforms.
The transformation functions are:
- scale(x,y): this will make every shape x times wider and y time taller.
- translate(x,y): now coordinate (0,0) will be shifted x units to the…
View original post 239 more words