Data Structures

Size2

Branded two-dimensional sizes with explicit validation.

Sizes model non-negative width/height pairs and are commonly used for colliders, viewports, and AABB dimensions.

Reach for this module when authored or host-provided dimensions should be validated once and then carried through gameplay code, runtime bootstrap, or geometry helpers without repeating non-negative checks everywhere.

Examples

// Validate raw viewport dimensions before storing or reusing them.
const viewport = Size2.result({ width: 800, height: 600 })
if (!viewport.ok) return

// Read the branded size later without rechecking width/height validity.
const width = Size2.width(viewport.value)

Construction

Non-throwing constructor boundaries that validate raw width and height input.

result

Source

Validates one raw size and returns an explicit result.

option

Source

Validates one raw size and returns null on failure.

is

Source

Checks whether one raw size already satisfies the size invariants.

Accessors

Pure readers and raw views over already-validated size values.

toRaw

Source

Converts one branded size back to a fresh raw object.

width

Source

Reads the width component of one branded size.

height

Source

Reads the height component of one branded size.