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. |