Skip to content
View source

Context builtinsGenerated

The builtins of kind context, as the compiler’s own table lists them.

Returns Function Requires
Bool button (n: Int) input.read
Double clock () time.read
Vec2 coord () +1 —
Int domain () +2 —
Int element () —
IVec2 icoord () +1 —
Int idomain () +2 —
Int index () —
Bool key (code: Int) input.read
Int pads () input.read
Vec2 pointer () input.read
Bool pointer_down () input.read
Int queued () time.read
Float rate () time.read
Float scale () input.read
Vec2 stick (n: Int) input.read
Float time () time.read
Int typed (k: Int) input.read
Vec2 wheel () input.read
Vec2 window () input.read
button(n: Int) -> Bool

Whether button n is held: 0 left, 1 right, 2 middle of a pointer; a pad’s from 8 (south, east, west, north, shoulders, thumbs, start, select).

Requires: input.read


clock() -> Double

The session’s time in seconds, whole: the same clock as time(), exact for years. Its Kernel runs where Doubles run.

Requires: time.read


coord() -> Vec2
coord() -> Vec3

This element’s column and row (and layer) over a grid or a volume, whole numbers from 0 with row 0 at the top; the element’s center is coord() + 0.5. Rows have element().

Callable from a Kernel body only


domain() -> Int
domain() -> Vec2
domain() -> Vec3

The output’s extent in its shape.

Callable from a Kernel body only


element() -> Int

This element’s index over rows; a scan’s step.

Callable from a Kernel body only


icoord() -> IVec2
icoord() -> IVec3

This element’s coordinates as integers, for arithmetic on cells.

Callable from a Kernel body only


idomain() -> Int
idomain() -> IVec2
idomain() -> IVec3

The output’s extent as integers.

Callable from a Kernel body only


index() -> Int

The iteration of the innermost loop, or a scan’s step outside every loop.


key(code: Int) -> Bool

Whether the key with this code is held, the browser’s codes: letters and digits by uppercase ASCII; backspace 8, tab 9, enter 13, shift 16, control 17, alt 18, escape 27, space 32, page up 33, page down 34, end 35, home 36, arrows 37 to 40 (left, up, right, down), delete 46, command or windows 91;; 186, = 187,, 188, - 189,. 190, / 191, ` 192, [ 219, \ 220, ] 221, ’ 222. A character typed with shift is the key under it on a US keyboard: ( is 57,: is 186.

Requires: input.read


pads() -> Int

How many pads are connected: a player shows a pad’s prompts while one is, whether or not it has been touched.

Requires: input.read


pointer() -> Vec2

The pointer in the output’s pixels from its top left; a player maps its window’s into them.

Requires: input.read


pointer_down() -> Bool

Whether the left button is held.

Requires: input.read


queued() -> Int

The samples (per channel) the sound device holds and has not yet played, zero without one: a sound made to the time can keep the device this far ahead.

Requires: time.read


rate() -> Float

The sound device’s samples per second, zero without one.

Requires: time.read


scale() -> Float

The window’s physical pixels per logical pixel, one without a window.

Requires: input.read


stick(n: Int) -> Vec2

A pad’s axis pair: 0 the left stick, 1 the right, 2 the two triggers (x left, y right). Sticks run -1 to 1 with y away from the person, triggers 0 to 1; all zero without a pad.

Requires: input.read


time() -> Float

The session’s time in seconds, rounded to a Float: finer than a millisecond for the first hours, a quarter second after a month. A session meant to run long times with clock().

Requires: time.read


typed(k: Int) -> Int

The kth character typed since the last evaluation, as a Unicode code point, 0 after the last: what the keyboard or an input method commits, Chinese as well as ASCII, 32 at most an evaluation (those past them wait for the next). key() tells which keys are held; typed() what they wrote.

Requires: input.read


wheel() -> Vec2

What the wheel scrolled since the last evaluation, in lines: x sideways, y positive away.

Requires: input.read


window() -> Vec2

The window’s size in physical pixels, zero by zero without one; a node’s domain may take it.

Requires: input.read