Learn html - html tutorial - Strokerect method in html5 canvas - html examples - html programs
- The strokeRect is a method of HTML <canvas> element.
- It is used to draw a no fill rectangle on the canvas.
- The default color of the filled rectangle is black.
- The default color of the strokeRect() is black.
Syntax for strokeRect() Method in HTML5 Canvas:
Parameter values for strokeRect() Method in HTML5 Canvas:
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 strokeRect() Method in HTML5 Canvas:
Code Explanation for strokeRect() Method in HTML5 Canvas:
- ”wikitechyCanvas” is used to define the value of id attribute for canvas element.
- The getElementById(); method is used to get the element that has the id attribute with the “wikiCanvas” value.
- a.getContext(“2d”) method is returns a two-dimensional drawing context on the canvas.
- The strokeRect() method is used to create a no fill rectangle in the canvas.
Output for strokeRect() Method in HTML5 Canvas:
- The canvas rectangle with green border.
- The black color rectangle shows that a rectangle drawn by using strokeRect() method.
Browser Support for strokeRect() Method in HTML5 Canvas:
Tips and Notes
- The strokeStyle property is used to set a color, gradient or pattern to style the stroke.
Related Searches to strokeRect() Method in HTML5 Canvas
javascript canvas stroke width
canvas draw rectangle with mouse
canvas draw rectangle fill
strokerect thickness
javascript strokestyle
javascript rect object
canvas draw rectangle android
html canvas stroke
Html5 Canvas
html tutorials