HTML5 draws complex shapes in canvas

Source: Internet
Author: User

Author: Qing Dujun

Address: http://blog.csdn.net/qingdujun/article/details/32942667


1. Draw complex shapes or paths

When a simple rectangle cannot meet the requirements, the following method is provided for drawing a complex shape or path.

  • BeginPath (): start to draw a new path.
  • ClosePath (): draws a line segment from the current point to the starting point of the path to close the shape.
  • Fill (), stroke (): fill shape or draw hollow shape.
  • MoveTo (): Move the current vertex to the point (x, y ).
  • LineTo (): draws a straight line (x, y) from the current point ).
  • Arc (x, y, r, sAngle, eAngle, counterclockwise): draws an arc-to-point (x, y) with a specified radius ).

2. Follow these steps to draw complex shapes

Iii. arc () Rendering instructions



4. Draw complex shapes in the canvas

<! -- <! DOCTYPE> Declaration must be the first line of the HTML document, located before the 

5. Draw Results



References: (printed) Shankar (. R .) (author ). xie Guanglei (translator ). HTML5 game development advanced Guide [M]. beijing: Electronics Industry Press, 2013.5-7.

W3School. HTML5canvas arc () method [CP/OL]. http://www.w3school.com.cn/tags/canvas_arc.asp ,? /2014-06-21.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.