Easily implement the HTML5 clock (share your understanding of canvas, which is not as difficult as you think)

Source: Internet
Author: User

Hey, guys! Let's use HTML5 to implement a simple clock!

 

When I came into contact with canvas, I suddenly felt very familiar with it. ------ the functions of canvas are actually different from those in Photoshop.Pen toolIs the same. So, if youPen toolCongratulations, canvas is coming soon ~~

To put it down, the canvas in HTML5 is translated into Chinese as a canvas. As the name suggests, canvas is certainly used for painting ~~

The idea of painting is basically the same as that of photoshop ~~, However, photoshop can be used as a visual tool, and HTML5/JS is just a matter of coding.

So to sum up, canvas is used for painting! As for what you want to draw, it's your own business!

 

GetContext ('2d ') in the canvas object is equivalentPen tool,The following describes their mappings:

BeginPath ----> start painting path

MoveTo -----> path start point

LineTo -------> draw a straight line path to a location

ClothPath ---> closed path

Stroke ------> stroke path (this is why when lineWidth is set to be greater than 1px, for example, 10px, it is divided by half from the center to the two sides, PSPen tool)

Fill -----------> fill path

BezierCurveTo and quadraticCurveTo are in PSThe essence of the Pen tool!

Wait ......

 

Well, if you are interested, you can go over the PSPen toolOh, I believe it will be helpful for you to understand the attributes and methods of getContext ('2d ') in the canvas object.

The following is the HTML5 clock implementation code:

1 <! Doctype html> 2  

You are welcome to shoot bricks. If there is a bug, please leave a message and remind me to help me with the recommendations ~~ Certificate ------------- Certificate

Bytes
Bytes
Bytes
Bytes
Bytes

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.