/

HTML / CSS / JavaScript Tutorial

JavaScript canvas2d object method: fillText()

[this page | pdf | back links]

The fillText() method of the JavaScript DOM object returned by the getContext("2d") method applied to the HTML <canvas> element draws ‘filled’ text.

 

It has the following syntax with the following parameters.

 

context.fillText(text, x, y, maxwidth)

 

Parameter

Required / Optional

Description

text

Required

String specifying text

x

Required

x-coordinate of upper-left corner (relative to canvas)

y

Required

y-coordinate of upper-left corner (relative to canvas)

maxwidth

Optional

Maximum width, in pixels

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile