PixiBackend
import { PixiBackend } from 'pixi-silk/i18n/pixi';
The PixiJS SilkBackend (brief sec. 2.3): atlas pages as textures, style rows as a data
texture, text buffers as instanced geometries, run sprites as one-glyph meshes drawn by the
message shader. Silk drives it. The core never touches Pixi.
Implements#
Constructors#
Constructor#
new PixiBackend(): PixiBackend;
Returns#
PixiBackend
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
pages | readonly | Map<number, TextureSource<any>> | Atlas pages by id. | packages/pixi-silk/src/i18n/pixi/backend.ts:54 |
styleRows | readonly | PixiStyleRows | The default style rows (themes keep their own, see SilkTheme). | packages/pixi-silk/src/i18n/pixi/backend.ts:56 |
Methods#
bindStyles()#
bindStyles(handle: TextBufferHandle, styles: TextureSource): void;
The style texture the buffer’s run sprites read (its message’s theme).
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
styles | TextureSource |
Returns#
void
createTextBuffer()#
createTextBuffer(capacityGlyphs: number): TextBufferHandle;
Makes a buffer for up to capacityGlyphs instances.
Parameters#
| Parameter | Type |
|---|---|
capacityGlyphs | number |
Returns#
Implementation of#
destroyTextBuffer()#
destroyTextBuffer(handle: TextBufferHandle): void;
Frees a buffer.
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
Returns#
void
Implementation of#
geometry()#
geometry(handle: TextBufferHandle): MessageGeometry;
The geometry of a text buffer, for the mesh that draws it.
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
Returns#
removeAtlasPage()#
removeAtlasPage(page: number): void;
Destroys a page no bundle uses any more. Not part of SilkBackend.
Parameters#
| Parameter | Type |
|---|---|
page | number |
Returns#
void
runSprite()#
runSprite(handle: TextBufferHandle, slot: number): Container<ContainerChild> | undefined;
The display object of a run sprite, positioned with the pen at 0, 0 on the baseline.
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
slot | number |
Returns#
Container<ContainerChild> | undefined
setRunSprite()#
setRunSprite(
handle: TextBufferHandle,
slot: number,
sprite: RunSprite | null
): void;
Sets or clears the run sprite of a text slot.
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
slot | number |
sprite | RunSprite | null |
Returns#
void
Implementation of#
uploadAtlasPage()#
uploadAtlasPage(
page: number,
source: Uint8Array<ArrayBufferLike> | ImageBitmap,
width: number,
height: number,
kind: "msdf" | "sdf" | "mtsdf"
): void;
Stores an atlas page: RGBA pixels (or a decoded image) of a page id.
Parameters#
| Parameter | Type |
|---|---|
page | number |
source | Uint8Array<ArrayBufferLike> | ImageBitmap |
width | number |
height | number |
kind | "msdf" | "sdf" | "mtsdf" |
Returns#
void
Implementation of#
writeInstances()#
writeInstances(
handle: TextBufferHandle,
firstGlyph: number,
data: ArrayBufferView
): void;
Writes instances from firstGlyph on. Writing from 0 also sets the instance count to what
was written. A later write (a number slot’s range) keeps the count.
Parameters#
| Parameter | Type |
|---|---|
handle | TextBufferHandle |
firstGlyph | number |
data | ArrayBufferView |
Returns#
void
Implementation of#
writeStyleRows()#
writeStyleRows(firstRow: number, rows: Float32Array): void;
Stores style rows from firstRow on.
Parameters#
| Parameter | Type |
|---|---|
firstRow | number |
rows | Float32Array |
Returns#
void