Coordinates — `Px` · `UV` · `px()` · `uv()`

Auto-generated from bridge/src/js/prelude/src/ on 2026-05-21. Run task gen:api-reference to refresh.

Two small classes for the two coordinate spaces the engine uses: Px for absolute integer pixel positions, UV for normalized [0..1] positions. The px() and uv() helpers are short factory functions for both.

← Back to API Reference index


Classes

Px

A pixel-space coordinate (integer position on the canvas).

No bounds checking — values may be outside the image for clamped/wrap ops. Use the px(x, y) factory for concise construction.

Accessors

tuple
Get Signature
get tuple(): [number, number];

Decompose into a plain [x, y] tuple.

Returns

[number, number]

Constructors

Constructor
new Px(x, y): Px;
Parameters
Parameter Type
x number
y number
Returns

Px

Methods

toString()
toString(): string;
Returns

string

Properties

Property Modifier Type
x readonly number
y readonly number

UV

A normalised UV coordinate with x, y ∈ [0..1], representing a relative position within an image (0 = start, 1 = end of that dimension).

Throws a RangeError on construction if either value is outside [0..1]. Use the uv(x, y) factory for concise construction.

Example

uv(0.5, 0.5)

Accessors

tuple
Get Signature
get tuple(): [number, number];

Decompose into a plain [x, y] tuple.

Returns

[number, number]

Constructors

Constructor
new UV(x, y): UV;
Parameters
Parameter Type
x number
y number
Returns

UV

Methods

toPx()
toPx(width, height): Px;

Convert to pixel coordinates given the image dimensions.

uv(0.5, 0.5).toPx(img.width, img.height) // → px(width/2, height/2)
Parameters
Parameter Type
width number
height number
Returns

Px

toString()
toString(): string;
Returns

string

Properties

Property Modifier Type
x readonly number
y readonly number

Functions

px()

function px(x, y): Px;

Create a pixel-space coordinate. Shorthand for new Px(x, y).

img.blendAt(other, px(100, 50), 1.0, Blend.Over);

Parameters

Parameter Type
x number
y number

Returns

Px


uv()

function uv(x, y): UV;

Create a normalised UV coordinate ∈ [0..1]. Shorthand for new UV(x, y). Throws if values are outside range.

uv(0.5, 0.5).toPx(img.width, img.height) // center of any image

Parameters

Parameter Type
x number
y number

Returns

UV