HTML Canvas Reference
HTML Canvas Reference
w3schools.com LOG IN
To learn more about <canvas> , please read our HTML Canvas tutorial.
fillStyle Sets or returns the color, gradient, or pattern used to fill the
drawing
strokeStyle Sets or returns the color, gradient, or pattern used for strokes
shadowOffsetX Sets or returns the horizontal distance of the shadow from the
shape
shadowOffsetY Sets or returns the vertical distance of the shadow from the
shape
https://www.w3schools.com/tags/ref_canvas.asp 1/10
9/14/2020 HTML Canvas Reference
Method Description
Line Styles
Property Description
lineCap Sets or returns the style of the end caps for a line
lineJoin Sets or returns the type of corner created, when two lines meet
Rectangles
Method Description
https://www.w3schools.com/tags/ref_canvas.asp 2/10
9/14/2020 HTML Canvas Reference
Paths
Method Description
moveTo() Moves the path to the specified point in the canvas, without
creating a line
closePath() Creates a path from the current point back to the starting point
lineTo() Adds a new point and creates a line to that point from the last
specified point in the canvas
clip() Clips a region of any shape and size from the original canvas
Transformations
Method Description
setTransform() Resets the current transform to the identity matrix. Then runs
transform()
https://www.w3schools.com/tags/ref_canvas.asp 3/10
9/14/2020 HTML Canvas Reference
Text
Property Description
font Sets or returns the current font properties for text content
textBaseline Sets or returns the current text baseline used when drawing
text
Method Description
measureText() Returns an object that contains the width of the specified text
Image Drawing
Method Description
Pixel Manipulation
Property Description
Method Description
getImageData() Returns an ImageData object that copies the pixel data for the
specified rectangle on a canvas
putImageData() Puts the image data (from a specified ImageData object) back
onto the canvas
Compositing
Property Description
Other
Method Description
createEvent()
getContext()
toDataURL()
❮ Previous Next ❯
https://www.w3schools.com/tags/ref_canvas.asp 5/10