CanvasContext.setTextBaseline
Set the properties of the current text baseline.
Parameters
It is Object type.
Property | Type | Value | Description |
textBaseline | String | top , hanging , middle , alphabetic , ideographic , bottom | The Canvas 2D API describes the properties of the current text baseline when drawing text. |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.setStrokeStyle('red')
ctx.moveTo(5, 75)
ctx.lineTo(295, 75)
ctx.stroke()
ctx.setFontSize(20)
ctx.setTextBaseline('top')
ctx.fillText('top', 5, 75)
ctx.setTextBaseline('middle')
ctx.fillText('middle', 50, 75)
ctx.setTextBaseline('bottom')
ctx.fillText('bottom', 120, 75)
ctx.setTextBaseline('normal')
ctx.fillText('normal', 200, 75)
ctx.draw()