Skip to main content

Module fit

Module fit 

Source
Expand description

fit / align — placing an animation inside a box the host laid out.

The player draws at authored scale into whatever target it is given, which is what a game wants and what a UI host cannot use: a UI host has a box and needs the art fitted into it. The vocabulary here is the family’s — contain / cover / none and nine alignments, the words <Image resizeMode> already taught every host — so this is a port of a settled contract rather than a new design.

Everything in this module is arithmetic over a box and a target size. There is no GPU work in it and no state, which is why it lives in the player where the C ABI and every adapter inherit it, rather than in one host’s adapter crate.

Structs§

Placed
A solved placement, in SSPlayer::set_transform’s terms: pixels from the view’s centre, y downward.
Placement
Everything that places an animation inside a view.
Rect
A box in player-local units — the space SSPlayer::part_transform reports in, with y downward and the origin where the animation was authored around.

Enums§

Align
Which point of the content box lands on the matching point of the view.
Fit
How the content box is scaled into the view.

Functions§

solve
Fit content into a view_width x view_height box.