Learn html - html tutorial - Clearrect method in html5 canvas - html examples - html programs
- The clearRect() is a method of HTML <canvas> element.
- It is used to erase a specified pixel in the canvas rectangle.
Syntax for clearRect() Method in HTML5 Canvas:
Attributes values for clearRect() Method in HTML5 Canvas:
ssssssssssssss
Value |
Description |
x |
The x axis coordinate of the rectangle starting point |
y |
The y axis coordinate of the rectangle starting point. |
width |
It is used to set a width for the rectangle. |
height |
It is used to set a height for the rectangle. |
Sample Coding for clearRect() Method in HTML5 Canvas:
Code Explanation for clearRect() Method in HTML5 Canvas:
- ”wikitechyCanvas” is used to define the id attribute value for canvas element.
- The getElementById(); method is used to get the element that has the id attributes value as “wikitechyCanvas”.
- a.getContext(“2d”) method is returns a two-dimensional drawing context on the canvas
- fillstyle property is used to fill the green color to the rectangle.
- The fillrect() method is used to draw a green color rectangle on the canvas with the help of fillStyle property.
- The clearRect() method is used to erase specified pixel from a filled rectangle on the canvas.
Output for clearRect() Method in HTML5 Canvas:
- The canvas rectangle with blue border.
- This shows that a rectangle drawn by using fillRect method.
- This shows that a clearRect() method is erase a specified pixel from a filled rectangle.
Browser Support for clearRect() Method in HTML5 Canvas:
Related Searches to clearRect() method in HTML5 Canvas
canvas clearrect not working
clear canvas jquery
canvas clearrect vs fillrect
chart js clear canvas
canvas clear stroke
clearrect java
canvas clear circle
canvas clearrect transparent
Html5 Canvas
html tutorials