<canvas>
element has 300px of width and 150px of height without any border and content. However, custom width and height can be defined using the CSS height
and width
property whereas the border can be applied using the CSS border
property.<canvas>
element is supported in all major web browsers such as Chrome, Firefox, Safari, Opera, IE 9 and above.window.onload
event will execute when the page load. Once the page is loaded, we can access the canvas element with document.getElementById()
method. Later we have defined a 2D canvas context by passing 2d into the getContext()
method of the canvas object.moveTo()
, lineTo()
and the stroke()
.moveTo()
method defines the position of drawing cursor onto the canvas, whereas the lineTo()
method used to define the coordinates of the line's end point, and finally the stroke()
method is used to make the line visible. Let's try out an example:arc()
method. The syntax of this method is as follow:rect()
method. This method requires four parameters x, y position of the rectangle and its width and height.rect()
method can be given with:rect()
method. However, you can create a fully enclosed arc such as circle using the arc()
method.arc()
method can be given with:strokeStyle
and lineWidth
property respectivley.lineCap
property. There are three styles available for the line caps — butt, round, and square. Here's an example:fillStyle()
method.fill()
method before the stroke()
How to install lftp centos commands windows 10. method in order to render the stroke correctly.fillStyle()
method to fill solid color inside a circle too.createLinearGradient()
method to fill a linear gradient color inside a rectangle. Let's try it out to understand how it basically works: Windows xp full.createRadialGradient()
method. The basic syntax for creating a radial gradient can be given with:createRadialGradient()
method to fill a radial gradient color inside a circle. Let's try it out to understand how it actually works:strokeText()
method. This method will color the perimeter of the text instead of filling it. However if you want to set both the fill and stroke on canvas text you can use both the fillText()
and the strokeText()
methods together.fillText()
method before the strokeText()
method in order to render the stroke correctly.