Home  >  Article  >  Web Front-end  >  HTML5 Drawing a rectangle in canvas with renderings_html5 tutorial skills

HTML5 Drawing a rectangle in canvas with renderings_html5 tutorial skills

WBOY
WBOYOriginal
2016-05-16 15:47:291505browse
1. Draw a rectangle

Canvas uses a coordinate system with the origin (0,0) in the upper left corner. The x coordinate increases to the right and the y coordinate increases downward.

Use the rectangle drawing function of the drawing environment to draw the rectangle.

fillRect(x,y,width,height): Draw a solid rectangle.
strokeRect(x,y,width,height): Draw a hollow rectangle.
clearRect(x,y,width,height): Clear the specified rectangular area to make it completely transparent.

2. Draw a rectangle in the canvas

Copy the code
The code is as follows :






HTML5





Tip: Your browser does not support the tag




3. Drawing Effect
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn