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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AvatarPainter(
atlas):AvatarPainter
A painter baking into atlas.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”AvatarPainter
Properties
Section titled “Properties”
readonlystats:PaintStats
Counts since it was made.
bakeGroups
Section titled “bakeGroups”bakeGroups:
boolean
Bake heads (true) or draw everything as vectors (comparisons).
Methods
Section titled “Methods”setTier()
Section titled “setTier()”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.
Parameters
Section titled “Parameters”"high" | "medium" | "low"
Returns
Section titled “Returns”void
draw()
Section titled “draw()”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.
Parameters
Section titled “Parameters”(s) => Texture
avatar
Section titled “avatar”string | AvatarDef
number
pixelScale
Section titled “pixelScale”number
Returns
Section titled “Returns”boolean
paint()
Section titled “paint()”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.
Parameters
Section titled “Parameters”(s) => Texture
shapes
Section titled “shapes”readonly AvatarShape[]
Mat | null
number
pixelScale
Section titled “pixelScale”number
depth?
Section titled “depth?”number
Returns
Section titled “Returns”void