Html5 canvas (Basic rectangle) and html5canvas rectangle

Source: Internet
Author: User

Html5 canvas (Basic rectangle) and html5canvas rectangle

Start with a simple

fillRect(x,y,width,height)

Add a width to the coordinates x and y, and the height is as follows:

FillRect (500,500, 500) // Add a rectangle with a width and a height of at coordinate

 

strokeRect(x,y,width,height)

Add a wide, high border rectangle to the coordinates x and y.

However, you need to use lineWidth, lineJoin, strokeStyle, and miterLimit to setThe following describes the rectangle function.

clearRect(x,y,width,height)

Clear the coordinates x and y. The height is completely transparent.

It feels a bit like a black layer in ps, pulling a rectangle and selecting a box, and then clicking a delect will make it transparent.

 

Set the filling style.

Context. fillStyle = '# 000000' // fill color context. strokeStyle =' # ff00ff '// border color

 

Complete code

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

 

The result is

If you don't know the previous structure, you can view my previous http://www.cnblogs.com/LoveOrHate/p/4388321.html.

 

Related Article

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.