Context builtinsGenerated
The builtins of kind context, as the compiler’s own table lists them.
Methods
Section titled “Methods”| 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 |
Method descriptions
Section titled “Method descriptions”button
Section titled “button”button(n: Int) -> BoolWhether 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() -> DoubleThe session’s time in seconds, whole: the same clock as time(), exact for years. Its Kernel runs where Doubles run.
Requires: time.read
coord() -> Vec2coord() -> Vec3This 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
Section titled “domain”domain() -> Intdomain() -> Vec2domain() -> Vec3The output’s extent in its shape.
Callable from a Kernel body only
element
Section titled “element”element() -> IntThis element’s index over rows; a scan’s step.
Callable from a Kernel body only
icoord
Section titled “icoord”icoord() -> IVec2icoord() -> IVec3This element’s coordinates as integers, for arithmetic on cells.
Callable from a Kernel body only
idomain
Section titled “idomain”idomain() -> Intidomain() -> IVec2idomain() -> IVec3The output’s extent as integers.
Callable from a Kernel body only
index() -> IntThe iteration of the innermost loop, or a scan’s step outside every loop.
key(code: Int) -> BoolWhether 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() -> IntHow 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
Section titled “pointer”pointer() -> Vec2The pointer in the output’s pixels from its top left; a player maps its window’s into them.
Requires: input.read
pointer_down
Section titled “pointer_down”pointer_down() -> BoolWhether the left button is held.
Requires: input.read
queued
Section titled “queued”queued() -> IntThe 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() -> FloatThe sound device’s samples per second, zero without one.
Requires: time.read
scale() -> FloatThe window’s physical pixels per logical pixel, one without a window.
Requires: input.read
stick(n: Int) -> Vec2A 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() -> FloatThe 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) -> IntThe 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() -> Vec2What the wheel scrolled since the last evaluation, in lines: x sideways, y positive away.
Requires: input.read
window
Section titled “window”window() -> Vec2The window’s size in physical pixels, zero by zero without one; a node’s domain may take it.
Requires: input.read

