API Reference › Types › Rect
type

Rect

Rect

Rect is an axis-aligned rectangle: four Q16.16 fixed components — the top-left corner (x, y) and the size (w, h) — packed into a single value that is copied by value and never heap-allocates. It is the natural type for HUD layout boxes, hitboxes, and camera or viewport regions. Build one with Rect.make(x, y, w, h), read the parts with Rect.x / Rect.y / Rect.w / Rect.h (or the derived Rect.right / Rect.bottom / Rect.center), and test against it with Rect.contains for a point and Rect.intersects for overlap. Every operation is deterministic fixed-point, so results are bit-identical on every platform.

Example

program Demo {
  handler Step phase Update {
    let button: Rect = Rect.make(8.0, 8.0, 96.0, 16.0)
    if Rect.contains(button, mx, my) { press() }
  }
}
← All symbols