HTML Dom tutorial 20-html Dom canvas object

Source: Internet
Author: User
ArticleDirectory
    • Height attribute
    • Width attribute

HTML Dom tutorial 20-html Dom canvas object

 

1: canvas object

The canvas object represents an HTML Canvas Element-<canvas>. It does not have its own behavior, but defines an API that supports script-based client plotting operations.

You can specify the width and height of the object directly, but most of its functions can be obtained through the canvasrenderingcontext2d object. This is obtained through the getcontext () method of the canvas object and passing the string "2D" as a unique parameter to it.

<Canvas> flag is introduced in Safari 1.3. When you create this reference page, it is also supported in Firefox 1.5 and opera 9. In ie, the <canvas> tag and Its APIs can be simulated using the javasercanvas open source project located in excanvas.sourceforge.net.

2: canvas Object Attributes Height attribute

The height of the canvas. Like an image, this attribute can be specified as an integer pixel value or a percentage of the window height. When this value changes, any drawing that has been completed on the canvas will be erased. The default value is 300.

Width attribute

The width of the canvas. Like an image, this attribute can be specified as an integer pixel value or a percentage of the window width. When this value changes, any drawing that has been completed on the canvas will be erased. The default value is 300.

3: canvas object Method
Method Description
Getcontext () Returns an environment for drawing on 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.