HTML5 new features of the canvas

Source: Internet
Author: User

1, the understanding of canvas

The canvas is a rectangular area within which the pixel control of each frame within the area can be controlled by JS.

2. js Operation Canvas Object

Canvas object. GetContext ("2d");//Get Canvas content

Set gradient

var grd=cxt.createlineargradient (0,0,175,50);

Grd.addcolorstop (0, "#FF0000")

Grd.addcolorstop (1, "#00FF00");

Ctx.fillstyle//Set Fill Color

Ctx.fillrect//Set fill position and size

Ctx.linewidth= "5"; Draw width

Cxt.strokestyle= "Red"; Draw Color

Cxt.beginpath (); Start drawing

Line drawing

Cxt.moveto (10,10); From where to start

Cxt.lineto (150,50); To where

Cxt.stroke (); How to Draw

Picture drawing

var img=new Image ()

Img.src= "Flower.png"

Cxt.drawimage (img,0,0);

Round drawing

Cxt.arc (70,18,15,0,math.pi*2,true);

Cxt.closepath (); Draw End

  

  

HTML5 new features of the canvas

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.