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

HTML5 Drawing a rectangle in canvas with renderings_html5 tutorial skills

WBOY
Release: 2016-05-16 15:47:29
Original
1535 people have browsed it
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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template