Home >Web Front-end >H5 Tutorial >Introduction to how to use the canvas element of html5 (drawing rectangles, polylines, circles)_html5 tutorial skills
Canvas generally refers to canvas. Recently, I have become more interested in using HTML5 to write games, so I simply used Canvas.
I have used Canvas in silverlight and wpf before. In silverlight, Canvas is an absolutely positioned container, and any control can be placed inside it. We can build canvas, graphics applications, GIS applications, etc. through him.
In HTML5, canvas is a new tag:
He also has a specific attribute:
For example, define the following canvas:
The size of the canvas in the picture is determined by style 600px * 450px, but the coordinates to fill the entire canvas are only 400*300, corresponding to the size in brackets.
Drawing in canvas is based on coordinates, so the coordinates of 100, 50 are converted into screen coordinates of 150px, 75px, and the size of the rectangle is also converted from 200*150 to the screen size of 300px*225px.
You can try it yourself by following the code below: