Options
All
  • Public
  • Public/Protected
  • All
Menu

Displays text on the canvas.

When using WebGL for rendering a second canvas is used for text.

Example

const text = new Text('Hello world.', { '20px monospace', '#333' })
text.pos.set(20, 20)

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

alpha

alpha: number

The opacity of the entity (from 0 to 1)

children

children: Partial<Entity>[]

An array of child entities for recursive update/render.

dead

dead: boolean

Whether or not the entity is dead.

pos

pos: Vec

Position of the entity.

scale

scale: Vec

Scale of the entity.

style

The styles used for the text.

text

text: string

The text to display.

visible

visible: boolean

Whether or not the entity is visible.

Accessors

hasChildren

  • get hasChildren(): boolean

Methods

add

  • add<T>(child: T): T
  • Add and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to add to the container.

    Returns T

map

  • map(fn: (child: Partial<Entity>, index?: number) => void): any
  • Map a function across all children.

    Parameters

    • fn: (child: Partial<Entity>, index?: number) => void

      Function to call for each child.

        • (child: Partial<Entity>, index?: number): void
        • Parameters

          • child: Partial<Entity>
          • Optional index: number

          Returns void

    Returns any

remove

  • remove<T>(child: T): T
  • Remove and return a child object.

    Type parameters

    • T

    Parameters

    • child: T

      Object to remove from the container.

    Returns T

update

  • update(_: number, __: number): void