Constructor
new FontImage(tileInfo)
Create an image font
Parameters:
| Name | Type | Description |
|---|---|---|
tileInfo | TileInfo | Tile info of first characeter in font |
- Source
Example
// use built in font
const font = engineFontImage;
// draw text
font.drawTextScreen('LittleJS\nHello World!', vec2(200, 50));Members
tileInfo
Properties| Type | Description |
|---|---|
| TileInfo | Tile info for the font |
- Source
Methods
drawText(text, pos, sizeopt, centeropt, coloropt, useWebGLopt, contextopt)
Draw text in world space using the image font
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | | |||
pos | Vector2 | |||
size | Vector2 | | <optional> | 1 | |
center | boolean | <optional> | true | |
color | Color | <optional> | WHITE | |
useWebGL | boolean | <optional> | glEnable | |
context | CanvasRenderingContext2D | | <optional> |
- Source
drawTextScreen(text, pos, size, centeropt, coloropt, useWebGLopt, contextopt)
Draw text in screen space using the image font
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | | |||
pos | Vector2 | |||
size | Vector2 | | |||
center | boolean | <optional> | true | |
color | Color | <optional> | WHITE | |
useWebGL | boolean | <optional> | glEnable | |
context | CanvasRenderingContext2D | | <optional> |
- Source