TextEntity
The TextEntity class extends Entity to render text strings on the canvas. It uses an internal PIXITextFix (a subclass of PIXI.Text) to handle text rendering correctly across WebGL and Canvas modes.
TextEntity
Extends Entity.
Properties
| Property | Type | Description |
|---|---|---|
text | PIXI.Text (PIXITextFix) | The underlying PIXI Text object. |
Methods
constructor()
ts
function constructor(text: string, fontName: string, fontSize: number): voidCreates a new text entity with the specified text string, font family, and font size. Sets the text resolution to 2 * devicePixelRatio to keep it sharp on high-DPI displays.
setColor()
ts
function setColor(r: number, g: number, b: number): voidSets the fill color of the text using RGB values (0-255).
setStroke()
ts
function setStroke(r: number, g: number, b: number, thickness: number): voidSets the stroke color and thickness of the text using RGB values.
setFontWeight()
ts
function setFontWeight(weight: string | number): voidSets the font weight (e.g. 'bold', 700).
setLetterSpacing()
ts
function setLetterSpacing(spacing: number): voidSets the letter spacing between text characters.
setAnchor()
ts
function setAnchor(x: number, y: number): voidSets the anchor point of the text.
setString()
ts
function setString(text: string): voidUpdates the string content of the text entity.