Skip to content

AvatarPainter

Turns avatar shape lists into renderer calls, baking rigid groups (heads) into an atlas. Nothing is allocated per frame once the heads are baked: a matrix stack by group depth, scratch point buffers, colours parsed once.

new AvatarPainter(atlas): AvatarPainter

A painter baking into atlas.

Atlas

AvatarPainter

readonly stats: PaintStats

Counts since it was made.


bakeGroups: boolean

Bake heads (true) or draw everything as vectors (comparisons).

setTier(tier): void

Follows the quality tier: on ‘low’ the heads are baked coarser (steps of 2, at most 256 pixels per unit), on the others finer. A change frees the heads baked so far; they bake again, at the new sizes, on their next draw.

"high" | "medium" | "low"

void


draw(r, tex, body, avatar, box, alpha, pixelScale): boolean

Draws one avatar posed like body in box (stage units). pixelScale: backing pixels per unit (bake sizes, curve flattening). Returns whether it drew (false: shoulders not seen). Below alpha 1 the avatar is drawn into an offscreen layer and composited at that alpha, so it is faint as a whole: its outlines and overlapping parts don’t show through each other.

Renderer

(s) => Texture

Body

string | AvatarDef

AvatarBox

number

number

boolean


paint(r, tex, shapes, m, alpha, pixelScale, depth?): void

Paints a shape list under the transform m (a similarity: translate, rotate, uniform scale) with an alpha.

Renderer

(s) => Texture

readonly AvatarShape[]

Mat | null

number

number

number

void