Skip to content
pixi-silk
GitHub repository
Class

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#

PropertyModifierTypeDescriptionDefined in
pagesreadonlyMap<number, TextureSource<any>>Atlas pages by id.packages/pixi-silk/src/i18n/pixi/backend.ts:54
styleRowsreadonlyPixiStyleRowsThe 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#

ParameterType
handleTextBufferHandle
stylesTextureSource

Returns#

void


createTextBuffer()#

createTextBuffer(capacityGlyphs: number): TextBufferHandle;

Makes a buffer for up to capacityGlyphs instances.

Parameters#

ParameterType
capacityGlyphsnumber

Returns#

TextBufferHandle

Implementation of#

SilkBackend.createTextBuffer


destroyTextBuffer()#

destroyTextBuffer(handle: TextBufferHandle): void;

Frees a buffer.

Parameters#

ParameterType
handleTextBufferHandle

Returns#

void

Implementation of#

SilkBackend.destroyTextBuffer


geometry()#

geometry(handle: TextBufferHandle): MessageGeometry;

The geometry of a text buffer, for the mesh that draws it.

Parameters#

ParameterType
handleTextBufferHandle

Returns#

MessageGeometry


removeAtlasPage()#

removeAtlasPage(page: number): void;

Destroys a page no bundle uses any more. Not part of SilkBackend.

Parameters#

ParameterType
pagenumber

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#

ParameterType
handleTextBufferHandle
slotnumber

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#

ParameterType
handleTextBufferHandle
slotnumber
spriteRunSprite | null

Returns#

void

Implementation of#

SilkBackend.setRunSprite


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#

ParameterType
pagenumber
sourceUint8Array<ArrayBufferLike> | ImageBitmap
widthnumber
heightnumber
kind"msdf" | "sdf" | "mtsdf"

Returns#

void

Implementation of#

SilkBackend.uploadAtlasPage


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#

ParameterType
handleTextBufferHandle
firstGlyphnumber
dataArrayBufferView

Returns#

void

Implementation of#

SilkBackend.writeInstances


writeStyleRows()#

writeStyleRows(firstRow: number, rows: Float32Array): void;

Stores style rows from firstRow on.

Parameters#

ParameterType
firstRownumber
rowsFloat32Array

Returns#

void

Implementation of#

SilkBackend.writeStyleRows