canvas-Dazzle's Countdown effect canvas drawing and animation basics

Source: Internet
Author: User

Canvas is drawn based on the turntable.

For a look at Canvas's browser compatibility issues, as shown in. (from can I use)

Tips: Just take to IE8 under the test, what reaction is not, in advance set up, if the browser does not support the prompt is not prompted, the developer tool in the element code is nothing.

Html:

<canvas id= "Canvas" style= "border:1px solid red;" ></canvas>

Js:

var canvas = document.getElementById (' canvas '); var context = Canvas.getcontext (' 2d ');
Note that the unit is not added, and it is not recommended to set the width height in CSS. It is best to call the width and height of the two properties canvas.width = 1024;canvas.height = 768;

 Practice: Draw a straight line (to be very careful, the state must first set to adjust the stroke () method to draw, if the order is reversed, will not result, and no error, debugger also tune no problem. )

First, the state Context.moveto (Context.lineto), Context.lineto (100, 100), and the Context.lineto. Context.linewidth = 10;context.strokestyle = "Pink";//re-input to draw context.stroke ();

 Define a path:

Context.moveto (+);  Accepts two parameters, representing x-coordinate and y-coordinate context.lineto (700, 700);

Define multiple paths: Wrap the state you want to define in the following way, and then call the stroke () method to draw lines of different states

Context.beginpath (); Context.closepath ();

  

Not finished ...

 

canvas-Dazzle's Countdown effect canvas drawing and animation basics

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.