Functions
colorToFloats
function colorToFloats(packed: number, out: Float32Array, o: number): void
From @phaser-ae/kernel
Unpack to four floats 0..1 (r, g, b, a) into out at offset o. For backends filling a uniform or vertex buffer.
packColor
function packColor(css: string): number
From @phaser-ae/kernel
Parse a CSS colour to packed rgba8 (0xRRGGBBAA, unsigned). Accepts ten named colours (white, black, red, green,
blue, yellow, cyan, magenta, orange, transparent), #rgb, #rgba, #rrggbb, #rrggbbaa, rgb() / rgba()
with 0–255 channels (clamped) and a 0–1 or percentage alpha, and hsl() / hsla() with a hue in degrees,
percentages, and a 0–1 or percentage alpha. Case and surrounding space are ignored. Throws on any other form, on a
hex digit that is not one, and on an rgb() with a part that is not a number or without three or four parts, so a
typo does not silently become black. hsl() is how a ramp is written by hand: hsl(${200 + i * 5}, 45%, 60%).
unpackColor
function unpackColor(packed: number): string
From @phaser-ae/kernel
Packed rgba8 → a CSS hex string: #rrggbb when alpha is 255, else #rrggbbaa.
wrapDelta
function wrapDelta(d: number, size: number): number
From @phaser-ae/kernel
The shortest signed equivalent of a difference d on a circle of size: on a 2000-wide world, 1999 − 1 = 1998 becomes −2. A size of 0 or less returns d.
wrapPos
function wrapPos(v: number, size: number): number
From @phaser-ae/kernel
v brought into [0, size). A size of 0 or less returns v.
Types
Cancel
interface Cancel
From @phaser-ae/kernel
Cancels something the kernel gave you: a subscription, a timer, a step, a scene disposer.
cancel(): void— Undo it. A second call does nothing.readonly cancelled: boolean— True once cancelled.
Color
type Color = string
From @phaser-ae/kernel
A CSS colour string at the API boundary ('#ff4444', 'red', 'hsl(200, 45%, 60%)'); packed rgba8 inside.
ColumnArray
type ColumnArray = Float32Array | Float64Array | Int32Array | Uint8Array | Uint16Array | Uint32Array
From @phaser-ae/kernel
The typed array behind a column, indexed by roster slot.
Columns
type Columns = Readonly<Record<string, ColumnType>>
From @phaser-ae/kernel
A pack's column declaration: column name → storage type.
ColumnType
type ColumnType = 'f32' | 'i32' | 'u8' | 'u32' | 'rgba8' | 'id'
From @phaser-ae/kernel
Column storage types a pack may declare in its columns. rgba8 reads and writes as a CSS colour; id is a u32.
Id
type Id = string & { readonly __id: unique symbol }
From @phaser-ae/kernel
Stable, human-legible, kernel-suffixed object id: enemy-crab-7. Never reused.
LayerName
type LayerName = string
From @phaser-ae/kernel
A layer name declared by a composed world pack, e.g. 'floor' | 'world' | 'fx'.
PackId
type PackId = string
From @phaser-ae/kernel
A pack's id as published: lighting-2d.
Radians
type Radians = number
From @phaser-ae/kernel
Radians. Never degrees in an API.
Rng
interface Rng
From @phaser-ae/kernel
The seeded random source: all chance in a game flows from here, never from Math.random, so the same seed and the
same steps replay the same game. xoshiro128** seeded by splitmix32.
readonly seed: number— The seed this stream started from, as an unsigned 32-bit integer.next(): number— A float in [0, 1).between(min: number, max: number): number— A float in [min, max).int(min: number, maxInclusive: number): number— An integer in [min, maxInclusive].chance(probability: number): boolean— True with the given probability, 0..1.pick<T>(items: ReadonlyArray<T>): T— One item, uniformly. Throwsrng.pick: emptyon an empty array.weighted<T>(items: ReadonlyArray<readonly [T, number]>): T— One item, by[item, weight]pairs; weights need not sum to 1. An empty list throws.shuffle<T>(items: T[]): T[]— Shuffleitemsin place (Fisher–Yates) and return the same array.fork(label: string): Rng— A child stream for one purpose (a level generator, a procgen job), seeded from this stream's seed andlabel. Drawing from it never disturbs this stream, and the same seed and label always give the same child, however far this stream has advanced.
Seconds
type Seconds = number
From @phaser-ae/kernel
Seconds, as a float. Never milliseconds.
Transform
interface Transform
From @phaser-ae/kernel
The kernel's transform columns. 2D worlds ignore z, pitch, roll and sz; 3D worlds use them.
x: number— Centre x, world units.y: number— Centre y, world units.z: number— z, world units; 3D worlds.rot: Radians— Rotation in radians: the turn on screen in 2D, the yaw about y in 3D.sx: number— Scale x.sy: number— Scale y.pitch: Radians— Pitch in radians about x; 3D worlds. 2D worlds leave it 0.roll: Radians— Roll in radians about z; 3D worlds. 2D worlds leave it 0.sz: number— Scale z; 3D worlds. 2D worlds leave it 1.
Wrap
interface Wrap
From @phaser-ae/kernel
The world's period in world units: positions live in [0, w) × [0, h).
readonly w: number— Width of the torus, world units.readonly h: number— Height of the torus, world units.
