![]() |
VOOZH | about |
The HTML “canvas” element is used to draw graphics via JavaScript. The “canvas” element is only a container for graphics. One must use JavaScript to actually draw the graphics. Canvas has several methods for drawing paths, boxes, circles, text, and adding images.
Example: This example shows the basic use of Canvas in HTML.
Output:
HTML Canvas Reference Complete Reference
Properties | Description |
|---|---|
| Return the color, gradient, or pattern used to fill the drawing. | |
| Return the stroke of color, gradient, or pattern used in the drawing. | |
| Set to a string representing a CSS color value, which we want as shadow color. | |
| Return the blur level for shadows. | |
| Return the horizontal distance of the shadow from the shape. | |
| Return the vertical distance of the shadow from the shape. |
Methods | Description |
|---|---|
| Gradient can be used to fill different colors in rectangles, circles, lines, text, etc | |
| It is used to repeat the specified element in the specified direction. | |
| It is used to specify the color and its position in the gradient object. |
Properties | Description |
|---|---|
| Set or return the style of end caps of line. | |
| Return the type of corner created, when two lines meet, by using the lineJoin property. | |
| Return the width of the line (thickness of the line). | |
| It is used to or returns the maximum miter length. |
Methods | Description |
|---|---|
| Create a rectangle in HTML. | |
| It is used to fill the rectangle using the given color. | |
| It is used to draw a rectangle in a given color. | |
| Clear the specified pixels within a given rectangle. |
Methods | Description |
|---|---|
| It is used to fill the current drawing path. | |
| Draw the path you have defined with all those moveTo() and lineTo() methods. | |
| It is used to start a path or reset the current path. | |
| Move the path to the specified point in the canvas, without creating a line. | |
| Create a path from the current point back to the starting point. | |
| It is used to add a new point to create a line from that point to the last specified point in the canvas | |
| It is used to clip a region/part of any shape and size from the given/original canvas. | |
| Create a quadratic curve on the canvas | |
| Bezier curves on HTML canvas are drawn using a start point, one or more control point/points, and an endpoint. | |
| Create an arc/curve i.e. circles or parts of circles. | |
| Create an arc/curve between two tangents on the canvas. | |
| Check whether or not the specified point is contained in the current path. |
Methods | Description |
|---|---|
| It is used to scale the current drawing into a smaller or larger size. | |
| It is used to rotate the drawing by a given angle. | |
| Specify that the object is translated by the given translation amount. | |
| It is used to replace the current transformation matrix | |
| It is used to replace the current transformation matrix |
Properties | Description |
|---|---|
| Change the present font family of the Text content of the <canvas> element. | |
| Return the current alignment for text content, according to the anchor point. | |
| Return the baseline of the current text. |
Methods | Description |
|---|---|
| fillText() | It is used to draw filled text on the canvas. |
| strokeText() | Draw text (with no fill) on the canvas, by using strokeText() Method. |
| measureText() | Return an object that represents the width of the specified text in terms of pixels. |
Properties | Description |
|---|---|
| It is used to specify the width of the <canvas> in terms of pixels. | |
| It is used to specify the height of the <canvas> element in terms of pixels. |
Methods | Description |
|---|---|
| It is used to create a new blank ImageData object. | |
| It is used to copy the pixel data for the specified rectangle on a canvas. | |
| It is used to put the image data back into the canvas from a specified ImageData object. |
Properties | Description |
|---|---|
| set or return the current alpha or transparency value of the drawing. |
Methods | Description |
|---|---|
| It is used to display an image or video on canvas. |