Skip to main content

Module sprites

Module sprites 

Source
Expand description

The scene as sprites for a GPU compositor other than wgpu: SpriteKit on watchOS, which gives an app no Metal of its own.

Every item becomes one quad in device pixels, drawn in order, cut to the whole pixels its clip leaves, as the rasterizer cuts it. The shapes the compositor’s shader covers – filled and stroked rounded rects, arcs and lines, painted with a solid colour or a two-colour gradient – travel as numbers. Everything else is drawn here, once, by the rasterizer into a texture of its own, which is kept while the item stays the same: moving it by whole pixels moves the quad and keeps the texture.

A sprite is SPRITE_FLOATS numbers; field names where each part starts. Positions are device pixels with the origin at the top left.

Modules§

field
Where each part of a sprite starts, and what it holds.

Structs§

SpriteFrame
One frame of sprites, and the textures they use. It keeps its textures from frame to frame: compose into the same one every frame.
TextureUpload
A texture the compositor has not seen yet: premultiplied RGBA8, row by row from the top.

Enums§

SpriteKind
What one sprite holds.

Constants§

SPRITE_FLOATS
How many numbers make one sprite.