Expand description
Aspect-preserving 2D canvas with one coordinate transform for drawing and input.
World positions use the caller’s authored units. Screens, content rectangles, offsets and pointer/touch positions use host logical pixels (Y down), relative to the full screen’s top-left. The host applies DPR only to the framebuffer; do not multiply these inputs by DPR or apply safe-area insets twice.
Structs§
- Canvas2D
- Fits a Y-down world into a logical-pixel screen, with aspect-preserving letterboxing. Uses camera zoom rather than a raw GPU viewport, so high-DPI screens behave identically. This transform does not scissor drawing outside the authored world bounds. Public fields remain available for existing struct literals; manually changed fields are the caller’s responsibility. Prefer the checked constructors.