writeTextToCanvas

writeTextToCanvas(text, options)Canvas

Writes the given text into a new canvas. The canvas will be sized to fit the text. If text is blank, returns undefined.
Name Type Description
text String The text to write.
options Object optional Object with the following properties:
Name Type Default Description
font String '10px sans-serif' optional The CSS font to use.
textBaseline String 'bottom' optional The baseline of the text.
fill Boolean true optional Whether to fill the text.
stroke Boolean false optional Whether to stroke the text.
fillColor Color Color.WHITE optional The fill color.
strokeColor Color Color.BLACK optional The stroke color.
strokeWidth Number 1 optional The stroke width.
backgroundColor Color Color.TRANSPARENT optional The background color of the canvas.
padding Number 0 optional The pixel size of the padding to add around the text.
Returns:
A new canvas with the given text drawn into it. The dimensions object from measureText will also be added to the returned canvas. If text is blank, returns undefined.