Skip to main content

Module layout

Module layout 

Source
Expand description

Design-space placement: the viewport scale every game recomputes, and the anchor/offset rectangle they all place panels with.

Two scales come out of one viewport: fit (the whole design rectangle is visible, so nothing is cropped) and cover (the design rectangle covers the viewport, so nothing is letterboxed). Games use fit for HUD and menus and cover for overlays that must reach past the design box.

anchor_rect is the games’ rect(vp, s, anchor, offset): the anchor is four viewport fractions (left, top, right, bottom) and the offset adds four design-unit distances to those edges before the right/bottom edges are clamped into the viewport. The left edge is not clamped, matching the copies, so an off-screen panel stays off-screen.

Structs§

AnchorEdges
The four design-space edges anchor_rect produces.
Scale
The two viewport scales, computed once per frame.

Enums§

ScaleError
Why a viewport or design box cannot produce a scale.

Constants§

DESIGN
The design box the template line draws at (960 x 540, 16:9).

Functions§

anchor_edges
Resolve an anchor and offset against a viewport.
anchor_rect
An absolutely positioned, full-bleed helper box: the games’ rect(...).
design_units
Pointer position in physical pixels to design units.
disc
A filled circle at a design-space point, with a design-unit radius.
ring
An unfilled circle: the virtual stick’s ring.