Canvas in the HTML5

Source: Internet
Author: User

The width of the 1.Canvas label must be set on the label or with JS to add attributes, if you use CSS to set the canvas will be stretched, equivalent to the default canvas stretched to the specified position. The default is 300px*100px;

<widthheight=400></canvas> 

Or

Canvas=document.getelementsbytagname (' canvas ') [0];canvas.width=500; canvas.height= 400;

This will solve the problem in the canvas.

2, the canvas drawing step order to step, or it will be covered according to the steps, attention!

3, a pixel in the canvas ask the question, because the canvas is filled from the middle to the sides of the drawing, but because the browser parsing, integer parsing (rounding) so there will be a pixel into two pixels of the problem, the solution, draw point offset 0.5;

Ctx.strokerect (10.5,10.5,100,100);

Canvas in the HTML5

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.