dither std/

arr
make(2)
reshape(2)
shape(1)
dict
clear(1)
delete(2)
has(2)
keys(1)
length(1)
values(1)
exch
decode(1)
encode(1)
JSON
data
font
decode(1)
decode(1)
FEAT_HIST
FEAT_KERN
FEAT_LIGA
FEAT_NONE
FEAT_ONUM
FEAT_SMCP
Font
advance(3)
advance(2)
glyph(2)
glyph(1)
id
lookup(2)
lookup(2)
H1_SANS
H1_SANS_SM
H1_SCPT
H2_ITAL
H2_ITAL_SM
H2_SANS
H2_SCPT
H2_SRIF
H2_SRIF_SM
H3_GOTH_DE
H3_GOTH_EN
H3_GOTH_IT
H3_ITAL
H3_SRIF
frag
begin(2)
begin(1)
end()
init(1)
program(1)
render()
texture(2)
Texture
fbo
read_pixels()
sample(1)
write_pixels(1)
uniform(2)
g3d
AXIS_X
AXIS_Y
AXIS_Z
background(4)
background(3)
background(1)
Camera
begin()
end()
look_at(3)
ortho(6)
perspective(4)
proj
view
DIRTY_COLORS
DIRTY_INDICES
DIRTY_NORMALS
DIRTY_UVS
DIRTY_VERTICES
flush()
init(1)
mat
id
rotate_deg(2)
scale(3)
scale(1)
translate(3)
Mesh
colors
draw(1)
indices
mode
normals
update(1)
uvs
vao
vertices
MODE_LINE_LIST
MODE_LINE_STRIP
MODE_POINT_LIST
MODE_TRIG_LIST
MODE_TRIG_STRIP
text(2)
gui
field(2)
get(1)
init()
poll()
set(2)
slider(4)
slider(4)
slider(4)
toggle(2)
guts
gc()
gc_off()
gc_on()
gx
apply_matrix(1)
background(4)
background(3)
background(1)
background(2)
begin_shape()
circle(3)
create_graphics(2)
ellipse(4)
end_shape(1)
end_shape()
fill(4)
fill(3)
fill(2)
fill(1)
Graphics
begin()
draw(4)
draw(2)
end()
fbo
h
read_pixels()
w
write_pixels(1)
line(4)
next_contour(1)
no_fill()
no_stroke()
point(2)
poll()
pop_matrix()
push_matrix()
rect(4)
reset_matrix()
rotate_deg(1)
scale(2)
scale(1)
size(2)
stroke(4)
stroke(3)
stroke(1)
stroke(2)
stroke_weight(1)
text(3)
translate(2)
vertex(2)
img
decode(1)
encode(2)
get(3)
set(4)
io
print(1)
println(1)
read_file(1)
write_file(2)
list
erase(3)
insert(3)
length(1)
make(2)
map(2)
pop(1)
push(2)
slice(3)
math
abs(1)
abs(1)
acos(1)
acos(1)
atan2(2)
atan2(2)
ceil(1)
ceil(1)
clamp(3)
cos(1)
cos(1)
exp(1)
exp(1)
floor(1)
floor(1)
hypot(2)
hypot(2)
lerp(3)
linmap(5)
max(2)
max(2)
min(2)
min(2)
PI
random()
round(1)
round(1)
sin(1)
sin(1)
sqrt(1)
sqrt(1)
tan(1)
tan(1)
rand
noise(3)
noise(2)
noise(1)
noise_detail(2)
noise_reseed()
random()
random(1)
random(1)
random(2)
seed(1)
req
http(1)
Request
body
headers
method
url
Response
body
headers
status
url
snd
buffer_full()
exit()
init(2)
put_sample(1)
str
chr(1)
decode(2)
encode(2)
length(1)
ord(1)
time
delay(1)
fps(1)
fps()
local(1)
local()
millis()
stamp()
vec
cross(2)
dir(1)
dot(2)
mag(1)
vin
create(2)
create(1)
EFFECT_MIRROR
RESO_FHD
RESO_HD
RESO_VGA
SOURCE_FILE
SOURCE_WEBCAM
Video
h
id
read_pixels()
w
win
CONTEXT_2D
CONTEXT_3D
Event
key
type
x
y
exit()
IDLE
init(3)
KEY_DARR
KEY_F1
KEY_F10
KEY_F11
KEY_F12
KEY_F2
KEY_F3
KEY_F4
KEY_F5
KEY_F6
KEY_F7
KEY_F8
KEY_F9
KEY_LALT
KEY_LARR
KEY_LCMD
KEY_LCTRL
KEY_LSHIFT
KEY_PRESSED
KEY_RALT
KEY_RARR
KEY_RCMD
KEY_RCTRL
KEY_RELEASED
KEY_RSHIFT
KEY_UARR
MOUSE_LEFT
MOUSE_MOVED
MOUSE_PRESSED
MOUSE_RELEASED
MOUSE_RIGHT
poll()
arr
Multidimensional homogeneous fixed-size mutable array
make[T,U](n:vec[i32,U],a:T):arr[T,U]
Generate an array given a shape and a filler item
PARAMETERS
nvec[i32,U]desired array shape
aTvalue to fill array with (mutable types are by-reference)
RETURNS
arr[T,U]new array
reshape[T,U](a:arr[T,U],n:vec[i32,U]):void
Change shape of an array. If new size is bigger, empty elements will be appended. If smaller, last elements will be discarded.
PARAMETERS
aarr[T,U]array to modify
nvec[i32,U]desired new shape
RETURNS
void
shape[T,U](a:arr[T,U]):vec[i32,U]
Retrieve shape of an array
PARAMETERS
aarr[T,U]array to query
RETURNS
vec[i32,U]array shape
dict
Mutable homogeneous collection of key-value pairs. Keys and values can be of any type, but keys are usually of immutable types.
clear[T,U](a:dict[T,U]):void
Remove all entries from a dict
PARAMETERS
adict[T,U]dict to modify
RETURNS
void
delete[T,U](a:dict[T,U],x:T):void
Remove an entry from a dict by key
PARAMETERS
adict[T,U]dict to modify
xTkey to remove
RETURNS
void
has[T,U](a:dict[T,U],x:T):i32
Check if a dict contains a given key
PARAMETERS
adict[T,U]dict to query
xTkey to check
RETURNS
i321 if dict contains key, 0 otherwise
keys[T,U](a:dict[T,U]):list[T]
Retrieve all keys of a dict into a list
PARAMETERS
adict[T,U]dict to query
RETURNS
list[T]a new list containing all keys
length[T,U](a:dict[T,U]):i32
Count the number of entries in a dict
PARAMETERS
adict[T,U]dict to query
RETURNS
i32number of entries
values[T,U](a:dict[T,U]):list[U]
Retrieve all values (as in key-value pairs) of a dict into a list
PARAMETERS
adict[T,U]dict to query
RETURNS
list[U]a new list containing all values (shallow copy)
exch
Data exchange formats serialization/deserialization
decode[T=JSON](src:str):T
Parse JSON from a string
PARAMETERS
srcstrstring to parse
RETURNS
TJSON parsed
encode(obj:JSON):str
Convert JSON to a string
PARAMETERS
objJSONJSON to serialize
RETURNS
strstring representing the JSON
JSONtype
Recursive datatype holding a JSON (javascript object notation)
data:union[list[JSON],dict[str,JSON],str,f32]
The data held: can be a list, a dict, a string or a number. Booleans are stored as numbers as the language does not have them.
font
decode(bytes:list[u8]):Font
PARAMETERS
byteslist[u8]
RETURNS
Font
decode(hfset:i32):Font
PARAMETERS
hfseti32
RETURNS
Font
FEAT_HIST:i32=4
FEAT_KERN:i32=65536
FEAT_LIGA:i32=256
FEAT_NONE:i32=0
FEAT_ONUM:i32=2
FEAT_SMCP:i32=1
Fonttype
advance(gidx:i32,hidx:i32,flag:u32):f32
PARAMETERS
gidxi32
hidxi32
flagu32
RETURNS
f32
advance(gidx:i32,hidx:i32):f32
PARAMETERS
gidxi32
hidxi32
RETURNS
f32
glyph(gidx:i32,reso:i32):list[list[vec[f32,2]]]
PARAMETERS
gidxi32
resoi32
RETURNS
list[list[vec[f32,2]]]
glyph(gidx:i32):list[list[vec[f32,2]]]
PARAMETERS
gidxi32
RETURNS
list[list[vec[f32,2]]]
id:i32
lookup(ch:i32,flag:u32):i32
PARAMETERS
chi32
flagu32
RETURNS
i32
lookup(lig:list[i32],flag:u32):i32
PARAMETERS
liglist[i32]
flagu32
RETURNS
i32
H1_SANS:i32=1
H1_SANS_SM:i32=13
H1_SCPT:i32=2
H2_ITAL:i32=6
H2_ITAL_SM:i32=7
H2_SANS:i32=12
H2_SCPT:i32=9
H2_SRIF:i32=10
H2_SRIF_SM:i32=11
H3_GOTH_DE:i32=4
H3_GOTH_EN:i32=3
H3_GOTH_IT:i32=5
H3_ITAL:i32=8
H3_SRIF:i32=14
frag
Fragment shader library. Can be used for shader-toy style pipeline, or in conjunction with std/g3d for shading 3D meshes.
begin(prgm:i32,tex:Texture):void
Start rendering with given shader program onto given texture
PARAMETERS
prgmi32shader program (from .program(...))
texTexturetexture to render to
RETURNS
void
begin(prgm:i32):void
Start rendering with given shader program onto default rendering target
PARAMETERS
prgmi32shader program (from .program(...))
RETURNS
void
end():void
Stop rendering with current shader program onto current texture
PARAMETERS
RETURNS
void
init(ctx:u64):void
Initialize the library. Required before calling any other functions from the library.
PARAMETERS
ctxu64the windowing context (from win.init(...))
RETURNS
void
program(src:str):i32
Compile a shader program from fragment shader source. The shader language is dependent on 3D backend; Better to generate with the `embed` statement.
PARAMETERS
srcstrfragment source code
RETURNS
i32handler representing the compiled shader program
render():void
Draw a rectangle filling the entire texture with the current shader program.
PARAMETERS
RETURNS
void
texture(w:i32,h:i32):Texture
Create a new texture. The texture can be used as both sampler and render target.
PARAMETERS
wi32desired width
hi32desired height
RETURNS
Texturea new texture
Texturetype
A datatype holding information for a texture on the GPU. A texture can be used as both sampler and render target.
fbo:i32
Internal ID/handler of the texture
read_pixels():arr[u8,3]
Download all pixel values from the GPU into an array
PARAMETERS
RETURNS
arr[u8,3]array holding RGBA colors of each pixel (0-255)
sample(uv:vec[f32,2]):vec[f32,4]
Read color at specific uv-coordinate on the texture. Mostly used in shaders.
PARAMETERS
uvvec[f32,2]normalized uv-coordinate (0-1)
RETURNS
vec[f32,4]RGBA color (0-1)
write_pixels(pix:arr[u8,3]):void
Upload pixel values from an array to the GPU
PARAMETERS
pixarr[u8,3]array holding desired RGBA colors of each pixel (0-255)
RETURNS
void
uniform[T](name:str,x:T):void
Set a uniform (global shader variable/parameter) for the current shader program.
PARAMETERS
namestrname of the uniform (matches name in shader)
xTthe desired value
RETURNS
void
g3d
3D graphics library.
AXIS_X:vec[f32,3]=1.,0.,0.
Unit vector for positive X axis
AXIS_Y:vec[f32,3]=0.,1.,0.
Unit vector for positive Y axis
AXIS_Z:vec[f32,3]=0.,0.,1.
Unit vector for positive Z axis
background(r:f32,g:f32,b:f32,a:f32):void
Clear graphics and fill with background color (RGBA 0-1)
PARAMETERS
rf32red
gf32green
bf32blue
af32alpha
RETURNS
void
background(r:f32,g:f32,b:f32):void
Clear graphics and fill with background color (RGB 0-1, A=1)
PARAMETERS
rf32red
gf32green
bf32blue
RETURNS
void
background(r:f32):void
Clear graphics and fill with background color (R=G=B 0-1, A=1)
PARAMETERS
rf32grayscale
RETURNS
void
Cameratype
Virtual camera for rendering 3D scenes
begin():void
Start using the camera
PARAMETERS
RETURNS
void
end():void
Stop using the camera
PARAMETERS
RETURNS
void
look_at(eye:vec[f32,3],targ:vec[f32,3],up:vec[f32,3]):void
Place the camera and orient toward given target. Sets the .view matrix of the camera.
PARAMETERS
eyevec[f32,3]camera position
targvec[f32,3]target position
upvec[f32,3]up vector
RETURNS
void
ortho(left:f32,right:f32,bottom:f32,top:f32,near:f32,far:f32):void
Use orthographic projection for the camera. Sets the .proj matrix of the camera.
PARAMETERS
leftf32left clipping plane
rightf32right clipping plane
bottomf32bottom clipping plane
topf32top clipping plane
nearf32near clipping plane
farf32far clipping plane
RETURNS
void
perspective(fovy:f32,aspect:f32,near:f32,far:f32):void
Use perspective projection for the camera. Sets the .proj matrix of the camera.
PARAMETERS
fovyf32field of view angle, in degrees, in the Y direction
aspectf32aspect ratio (X/Y)
nearf32near clipping plane
farf32far clipping plane
RETURNS
void
proj:vec[f32,4,4]=1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.
Projection matrix (as in model-view-projection) of the camera
view:vec[f32,4,4]=1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.
View matrix (as in model-view-projection) of the camera
DIRTY_COLORS:i32=4
Flag for Mesh.update() to indicate mesh colors are modified
DIRTY_INDICES:i32=2
Flag for Mesh.update() to indicate mesh indices are modified
DIRTY_NORMALS:i32=16
Flag for Mesh.update() to indicate mesh normals are modified
DIRTY_UVS:i32=8
Flag for Mesh.update() to indicate mesh UVs are modified
DIRTY_VERTICES:i32=1
Flag for Mesh.update() to indicate mesh vertices are modified
flush():void
Flush queued commands to GPU (no-op on some backends)
PARAMETERS
RETURNS
void
init(ctx:u64):void
Initialize the library. Required before calling any other functions from the library.
PARAMETERS
ctxu64the windowing context (from win.init(...))
RETURNS
void
mat
Sub-namespace containing utilities for constructing transformation matrices
id:vec[f32,4,4]=1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.
The 4x4 identity matrix
rotate_deg(axis:vec[f32,3],ang:f32):vec[f32,4,4]
Generate a matrix that can rotate vectors around given axis by given degrees
PARAMETERS
axisvec[f32,3]axis of rotation
angf32angle in degrees
RETURNS
vec[f32,4,4]rotation matrix
scale(x:f32,y:f32,z:f32):vec[f32,4,4]
Generate a matrix that can scale vectors by given factor on each axis
PARAMETERS
xf32scale factor on X axis
yf32scale factor on Y axis
zf32scale factor on Z axis
RETURNS
vec[f32,4,4]scale matrix
scale(x:f32):vec[f32,4,4]
Generate a matrix that can scale vectors uniformly on all axes by given factor
PARAMETERS
xf32scale factor
RETURNS
vec[f32,4,4]scale matrix
translate(x:f32,y:f32,z:f32):vec[f32,4,4]
Generate a matrix that can translate (move) vectors by given offset on each axis
PARAMETERS
xf32offset on X axis
yf32offset on Y axis
zf32offset on Z axis
RETURNS
vec[f32,4,4]translation matrix
Meshtype
Datatype holding a 3D mesh
colors:list[vec[f32,4]]
Per-vertex color buffer, RGBA 0-1 for each vertex. Optionally empty.
draw(transform:vec[f32,4,4]):void
Draw the mesh, given a transformation, using current shader and camera config onto current render target.
PARAMETERS
transformvec[f32,4,4]transformation (a.k.a. model as in model-view-projection) matrix
RETURNS
void
indices:list[i32]
Vertex index buffer, specifying vertex winding. Zero-indexed. Optionally empty.
mode:i32=MODE_TRIG_LIST
Winding/primitive mode for indices
normals:list[vec[f32,3]]
Per-vertex normal buffer. Optionally empty
update(flags:i32):void
Upload buffers indicated by given flags to GPU
PARAMETERS
flagsi32a bitwise OR of .DIRTY_* flags, e.g. .DIRTY_VERTICES|.DIRTY_COLORS
RETURNS
void
uvs:list[vec[f32,2]]
UV (texcoords) buffer. Normalized 0-1. Optionally empty.
vao:i32=-1
Internal ID/handler of the mesh
vertices:list[vec[f32,3]]
Vertex buffer
MODE_LINE_LIST:i32=0x0001
Primitive mode for disjoint lines
MODE_LINE_STRIP:i32=0x0003
Primitive mode for a polyline
MODE_POINT_LIST:i32=0x0000
Primitive mode for point cloud
MODE_TRIG_LIST:i32=0x0004
Primitive mode for disjoint triangles
MODE_TRIG_STRIP:i32=0x0005
Primitive mode for connected strip of triangles
text(s:str,transform:vec[f32,4,4]):void
Draw text using built-in monospace fixed-size pixel font
PARAMETERS
sstrstring containing text to draw
transformvec[f32,4,4]transformation matrix
RETURNS
void
gui
field(name:str,x:str):void
PARAMETERS
namestr
xstr
RETURNS
void
get[T](name:str):T
PARAMETERS
namestr
RETURNS
T
init():void
PARAMETERS
RETURNS
void
poll():void
PARAMETERS
RETURNS
void
set[T](name:str,x:T):void
PARAMETERS
namestr
xT
RETURNS
void
slider(name:str,x:f32,l:f32,r:f32):void
PARAMETERS
namestr
xf32
lf32
rf32
RETURNS
void
slider(name:str,x:i32,l:i32,r:i32):void
PARAMETERS
namestr
xi32
li32
ri32
RETURNS
void
slider[T,N](name:str,x:vec[T,N],l:vec[T,N],r:vec[T,N]):void
PARAMETERS
namestr
xvec[T,N]
lvec[T,N]
rvec[T,N]
RETURNS
void
toggle(name:str,x:i32):void
PARAMETERS
namestr
xi32
RETURNS
void
guts
Runtime internals
gc():void
Trigger garbage collection as soon as possible
PARAMETERS
RETURNS
void
gc_off():void
Disable garbage collection
PARAMETERS
RETURNS
void
gc_on():void
Enable garbage collection
PARAMETERS
RETURNS
void
gx
2D Processing-like graphics library
apply_matrix(x:vec[f32,3,3]):void
Set current transformation matrix to product of given matrix and the current matrix
PARAMETERS
xvec[f32,3,3]transformation to apply
RETURNS
void
background(r:f32,g:f32,b:f32,a:f32):void
Fill the render target with given color (RGBA 0-1)
PARAMETERS
rf32red
gf32green
bf32blue
af32alpha
RETURNS
void
background(r:f32,g:f32,b:f32):void
Fill the render target with given color (RGB 0-1, A=1)
PARAMETERS
rf32red
gf32green
bf32blue
RETURNS
void
background(r:f32):void
Fill the render target with given grayscale value (R=G=B 0-1, A=1)
PARAMETERS
rf32grayscale
RETURNS
void
background(r:f32,a:f32):void
Fill the render target with given grayscale and alpha value (R=G=B 0-1, A 0-1)
PARAMETERS
rf32grayscale
af32alpha
RETURNS
void
begin_shape():void
Start drawing a polyline/polygon
PARAMETERS
RETURNS
void
circle(x:f32,y:f32,d:f32):void
Draw a circle
PARAMETERS
xf32center X
yf32center Y
df32diameter
RETURNS
void
create_graphics(w:i32,h:i32):Graphics
Create an offscreen render target
PARAMETERS
wi32desired width
hi32desired height
RETURNS
Graphicsa new render target
ellipse(x:f32,y:f32,w:f32,h:f32):void
Draw an ellipse
PARAMETERS
xf32center X
yf32center Y
wf32diameter X
hf32diameter Y
RETURNS
void
end_shape(close:i32):void
Stop drawing a polyline/polygon
PARAMETERS
closei321 to close the shape (polygon), 0 otherwise (polyline)
RETURNS
void
end_shape():void
Stop drawing a polygon (close the shape)
PARAMETERS
RETURNS
void
fill(r:f32,g:f32,b:f32,a:f32):void
Set fill color (RGBA 0-1)
PARAMETERS
rf32red
gf32green
bf32blue
af32alpha
RETURNS
void
fill(r:f32,g:f32,b:f32):void
Set fill color (RGB 0-1, A=1)
PARAMETERS
rf32red
gf32green
bf32blue
RETURNS
void
fill(r:f32,a:f32):void
Set fill color (R=G=B 0-1, A 0-1)
PARAMETERS
rf32grayscale
af32alpha
RETURNS
void
fill(r:f32):void
Set fill color (R=G=B 0-1, A=1)
PARAMETERS
rf32grayscale
RETURNS
void
Graphicstype
Datatype for an offscreen render target
begin():void
Start drawing on this render target
PARAMETERS
RETURNS
void
draw(x:f32,y:f32,w:f32,h:f32):void
Draw this render target as an image/texture onto current render target (with scaling)
PARAMETERS
xf32left coordinate to draw to
yf32top coordinate to draw to
wf32width after scaling
hf32height after scaling
RETURNS
void
draw(x:f32,y:f32):void
Draw this render target as an image/texture onto current render target (without scaling)
PARAMETERS
xf32left coordinate to draw to
yf32top coordinate to draw to
RETURNS
void
end():void
Stop drawing on this render target (return to default render target)
PARAMETERS
RETURNS
void
fbo:i32
Internal ID/handler of the render target
h:i32
Height in pixels
read_pixels():arr[u8,3]
Download all pixel values into an array
PARAMETERS
RETURNS
arr[u8,3]array holding RGBA colors of each pixel (0-255)
w:i32
Width in pixels
write_pixels(pix:arr[u8,3]):void
Upload pixel values from an array
PARAMETERS
pixarr[u8,3]array holding desired RGBA colors of each pixel (0-255)
RETURNS
void
line(x0:f32,y0:f32,x1:f32,y1:f32):void
Draw a line
PARAMETERS
x0f32X coordinate of one end
y0f32Y coordinate of one end
x1f32X coordinate of the other end
y1f32Y coordinate of the other end
RETURNS
void
next_contour(close:i32):void
For shapes with multiple contours (holes, islands, etc.), this marks the start of the next contour.
PARAMETERS
closei321 to close the previous contour, 0 otherwise
RETURNS
void
no_fill():void
Disable fill
PARAMETERS
RETURNS
void
no_stroke():void
Disable stroke
PARAMETERS
RETURNS
void
point(x:f32,y:f32):void
Draw a point. Color is affected by .stroke(...)
PARAMETERS
xf32X coordinate
yf32Y coordinate
RETURNS
void
poll():win.Event
Flush graphics and listen for windowing events. Non-blocking. Wraps win.poll()
PARAMETERS
RETURNS
win.Eventa windowing event (might be IDLE)
pop_matrix():void
Restore transformation to previously saved state
PARAMETERS
RETURNS
void
push_matrix():void
Save current transformation matrix state
PARAMETERS
RETURNS
void
rect(x:f32,y:f32,w:f32,h:f32):void
Draw a rectangle
PARAMETERS
xf32left coordinate
yf32top coordinate
wf32width
hf32height
RETURNS
void
reset_matrix():void
Reset transformation matrix to identity matrix
PARAMETERS
RETURNS
void
rotate_deg(x:f32):void
Rotate subsequent drawings by modifying the current transformation matrix.
PARAMETERS
xf32angle in degrees
RETURNS
void
scale(x:f32,y:f32):void
Scale subsequent drawings by modifying the current transformation matrix.
PARAMETERS
xf32factor on X axis
yf32factor on Y axis
RETURNS
void
scale(x:f32):void
Scale subsequent drawings uniformly on both axes by modifying the current transformation matrix.
PARAMETERS
xf32factor on both axes
RETURNS
void
size(w:i32,h:i32):void
Set up the window and the default render target. Wraps win.init(...)
PARAMETERS
wi32width
hi32height
RETURNS
void
stroke(r:f32,g:f32,b:f32,a:f32):void
Set stroke color (RGBA 0-1)
PARAMETERS
rf32red
gf32green
bf32blue
af32alpha
RETURNS
void
stroke(r:f32,g:f32,b:f32):void
Set stroke color (RGB 0-1, A=1)
PARAMETERS
rf32red
gf32green
bf32blue
RETURNS
void
stroke(r:f32):void
Set stroke color (R=G=B 0-1, A=1)
PARAMETERS
rf32grayscale
RETURNS
void
stroke(r:f32,a:f32):void
Set stroke color (R=G=B 0-1, A 0-1)
PARAMETERS
rf32grayscale
af32alpha
RETURNS
void
stroke_weight(w:f32):void
Set stroke width/weight/thickness
PARAMETERS
wf32thickness in pixels
RETURNS
void
text(s:str,x:f32,y:f32):void
Draw text using built-in monospace fixed-size pixel font
PARAMETERS
sstrstring containing the text
xf32left coordinate
yf32bottom coordinate
RETURNS
void
translate(x:f32,y:f32):void
Translate (offset) subsequent drawings by modifying the current transformation matrix.
PARAMETERS
xf32X offset
yf32Y offset
RETURNS
void
vertex(x:f32,y:f32):void
Add a vertex to the polyline/polygon currently being drawn
PARAMETERS
xf32X coordinate
yf32Y coordinate
RETURNS
void
img
Imaging library
decode(buf:list[u8]):arr[u8,3]
Decode an image stored in a supported format (PNG, JPG, ...). The format is automatically detected
PARAMETERS
buflist[u8]list of bytes holding the image in its encoded form
RETURNS
arr[u8,3]array of pixels (RGBA 0-255)
encode(ext:str,pix:arr[u8,3]):list[u8]
Encode an image to a supported format (PNG, JPG, ...)
PARAMETERS
extstrimage format, specified as file extension
pixarr[u8,3]array of pixels (RGBA 0-255)
RETURNS
list[u8]list of bytes holding the encoded form
get[T](pix:arr[T,3],x:i32,y:i32):vec[T,4]
Retrieve the color of a single pixel in an image
PARAMETERS
pixarr[T,3]array of pixels
xi32X coordinate
yi32Y coordinate
RETURNS
vec[T,4]pixel color components at given coordinate
set[T](pix:arr[T,3],x:i32,y:i32,c:vec[T,4]):void
Set the color of a single pixel in an image
PARAMETERS
pixarr[T,3]array of pixels
xi32X coordinate
yi32Y coordinate
cvec[T,4]pixel color components
RETURNS
void
io
Input/output library: File and console I/O
print(s:str):void
Print a string to the console
PARAMETERS
sstrstring to print
RETURNS
void
println(s:str):void
Print a string to the console, terminated by a newline (LF 0xA)
PARAMETERS
sstrstring to print
RETURNS
void
read_file(s:str):list[u8]
Read a file to a list of bytes
PARAMETERS
sstrpath to file (or URL on some backends)
RETURNS
list[u8]list of bytes
write_file(s:str,buf:list[u8]):void
Write a file given a list of bytes to write
PARAMETERS
sstrpath to file (or URL on some backends)
buflist[u8]list of bytes
RETURNS
void
list
Ordered, variable-size collection of homogeneous items
erase[T](a:list[T],i:i32,j:i32):i32
Remove elements in a given index range from a list
PARAMETERS
alist[T]list to modify
ii32start index (inclusive)
ji32end index (exclusive)
RETURNS
i32new length of list
insert[T](a:list[T],i:i32,x:T):i32
Insert an element before a given index into a list
PARAMETERS
alist[T]list to modify
ii32the element will be of this index after insertion
xTthe element to insert
RETURNS
i32new length of list
length[T](a:list[T]):i32
Retrieve the length of a list
PARAMETERS
alist[T]list to query
RETURNS
i32length of the list
make[T](n:i32,a:T):list[T]
Generate a new list given desired length and filler item
PARAMETERS
ni32desired length
aTvalue to fill list with (mutable types are by-reference)
RETURNS
list[T]new list
map[T,U](a:list[T],f:func[tup[T],U]):list[U]
Apply a function to each element of a list and return a new list containing the results. The original list is not modified
PARAMETERS
alist[T]list whose elements will be input to the function, in order
ffunc[tup[T],U]the function to apply to each element
RETURNS
list[U]new list containing the results
pop[T](a:list[T]):T
Remove the last element from a list and return it
PARAMETERS
alist[T]list to modify
RETURNS
TThe (previously) last element
push[T](a:list[T],x:T):i32
Add an element to the end of a list
PARAMETERS
alist[T]list to modify
xTelement to be pushed
RETURNS
i32new length of list
slice[T](a:list[T],i:i32,j:i32):list[T]
Shallow copy a portion of a list into a new list
PARAMETERS
alist[T]list to be sliced
ii32start index (inclusive)
ji32end index (exclusive)
RETURNS
list[T]new list containing the sliced elements
math
Math library
abs(x:f32):f32
Absolute value
PARAMETERS
xf32input
RETURNS
f32outut
abs[N](x:vec[f32,N]):vec[f32,N]
Element-wise absolute value of vector
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output
acos(x:f32):f32
Arccosine
PARAMETERS
xf32input
RETURNS
f32output in radians
acos[N](x:vec[f32,N]):vec[f32,N]
Element-wise arccosine of a vector
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output in radians
atan2(x:f32,y:f32):f32
2-argument arctangent
PARAMETERS
xf32dividend
yf32divisor
RETURNS
f32output
atan2[N](x:vec[f32,N],y:vec[f32,N]):vec[f32,N]
Element-wise 2-argument arctangent of vectors
PARAMETERS
xvec[f32,N]dividend
yvec[f32,N]divisor
RETURNS
vec[f32,N]output
ceil(x:f32):f32
Ceiling (round up)
PARAMETERS
xf32input
RETURNS
f32output
ceil[N](x:vec[f32,N]):vec[f32,N]
Element-wise ceiling of a vector (round up)
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output
clamp[T](x:T,a:T,b:T):T
Clamp a value between two extrema, min(max(x,a),b)
PARAMETERS
xTvalue
aTlower bound
bTupper bound
RETURNS
Tclamped value
cos(x:f32):f32
Cosine
PARAMETERS
xf32input in radians
RETURNS
f32output
cos[N](x:vec[f32,N]):vec[f32,N]
Element-wise cosine of a vector
PARAMETERS
xvec[f32,N]input in radians
RETURNS
vec[f32,N]output
exp(x:f32):f32
Exponential. Computes e^x
PARAMETERS
xf32the exponent
RETURNS
f32power
exp[N](x:vec[f32,N]):vec[f32,N]
Element-wise exponential of a vector. Computes e^x
PARAMETERS
xvec[f32,N]the exponent
RETURNS
vec[f32,N]power
floor(x:f32):f32
Floor (round down)
PARAMETERS
xf32input
RETURNS
f32output
floor[N](x:vec[f32,N]):vec[f32,N]
Element-wise floor of a vector (round down)
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output
hypot(x:f32,y:f32):f32
Hypothenuse. Square root of the sum of the squares of the arguments.
PARAMETERS
xf32first argument
yf32second argument
RETURNS
f32output
hypot[N](x:vec[f32,N],y:vec[f32,N]):vec[f32,N]
Element-wise hypothenuse of vectors. Square root of the sum of the squares of the arguments.
PARAMETERS
xvec[f32,N]first argument
yvec[f32,N]second argument
RETURNS
vec[f32,N]output
lerp[T](x:T,y:T,t:f32):T
Liner interpolation
PARAMETERS
xTlower end
yThigher end
tf32interpolant
RETURNS
Tinterpolated value
linmap[T](x:T,ilo:T,ihi:T,olo:T,ohi:T):T
Linearly map a value from one range to another
PARAMETERS
xTvalue
iloTinitial lower end
ihiTinitial higher end
oloToncoming lower end
ohiToncoming higher end
RETURNS
Tremapped value
max(x:f32,y:f32):f32
Maximum of two numbers
PARAMETERS
xf32first argument
yf32second argument
RETURNS
f32output
max[N](x:vec[f32,N],y:vec[f32,N]):vec[f32,N]
Element-wise maximum of two vectors
PARAMETERS
xvec[f32,N]first argument
yvec[f32,N]second argument
RETURNS
vec[f32,N]output
min(x:f32,y:f32):f32
Minimum of two numbers
PARAMETERS
xf32first argument
yf32second argument
RETURNS
f32output
min[N](x:vec[f32,N],y:vec[f32,N]):vec[f32,N]
Element-wise minimum of two vectors
PARAMETERS
xvec[f32,N]first argument
yvec[f32,N]second argument
RETURNS
vec[f32,N]output
PI:f32=3.141592653589793
The mathematical constant pi, ratio of the circumference of a circle to its diameter
random():f32
Generate a random fraction between 0 and 1 with uniform distribution. Use std/rand instead for more parameterized randomness
PARAMETERS
RETURNS
f32output
round(x:f32):f32
Round a number to the nearest whole number
PARAMETERS
xf32input
RETURNS
f32output
round[N](x:vec[f32,N]):vec[f32,N]
Element-wise round a vector to nearest whole numbers
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output
sin(x:f32):f32
Sine
PARAMETERS
xf32input in radians
RETURNS
f32output
sin[N](x:vec[f32,N]):vec[f32,N]
Element-wise sine of a vector
PARAMETERS
xvec[f32,N]input in radians
RETURNS
vec[f32,N]output
sqrt(x:f32):f32
Square root
PARAMETERS
xf32input
RETURNS
f32output
sqrt[N](x:vec[f32,N]):vec[f32,N]
Element-wise square root of a vector
PARAMETERS
xvec[f32,N]input
RETURNS
vec[f32,N]output
tan(x:f32):f32
Tangent
PARAMETERS
xf32input in radians
RETURNS
f32output
tan[N](x:vec[f32,N]):vec[f32,N]
element-wise tangent of a vector
PARAMETERS
xvec[f32,N]input in radians
RETURNS
vec[f32,N]output
rand
Library for various flavors of randomness and noise
noise(x:f32,y:f32,z:f32):f32
3D fractal Perlin noise
PARAMETERS
xf32sample X
yf32sample Y
zf32sample Z
RETURNS
f32noise value (0-1)
noise(x:f32,y:f32):f32
2D fractal Perlin noise
PARAMETERS
xf32sample X
yf32sample Y
RETURNS
f32noise value (0-1)
noise(x:f32):f32
1D fractal Perlin noise
PARAMETERS
xf32sample coordinate
RETURNS
f32noise value (0-1)
noise_detail(lod:i32,falloff:f32):void
Config fractal Perlin noise parameters
PARAMETERS
lodi32level of detail (fractal octave count)
fallofff32diminish factor on each subsequent octave
RETURNS
void
noise_reseed():void
Re-seed fractal Perlin noise with .random()
PARAMETERS
RETURNS
void
random():f32
Generate uniformly distributed random fraction between 0-1
PARAMETERS
RETURNS
f32the random number
random(a:f32):f32
Generate uniformly distributed random number between 0 and given upper bound
PARAMETERS
af32upper bound
RETURNS
f32the random number
random[N](a:vec[f32,N]):vec[f32,N]
Generate uniformly distributed random vector between 0 and given upper bound
PARAMETERS
avec[f32,N]element-wise upper bound
RETURNS
vec[f32,N]the random vector
random[T](a:T,b:T):T
Generate random value in given range
PARAMETERS
aTlower bound
bTupper bound
RETURNS
Tthe random value
seed(x:u32):void
Seed the .random() generator
PARAMETERS
xu32the seed
RETURNS
void
req
Network client library for HTTP etc.
http(rq:Request):Response
Make an HTTP(S) request
PARAMETERS
rqRequestthe request
RETURNS
Responsethe response
Requesttype
Datatype holding information needed for a request
body:list[u8]
Bytes holding the body
headers:list[str]
List of headers
method:str="GET"
The method, GET, POST, DELETE, etc.
url:str=""
Requested address
Responsetype
Datatype holding information retrieved from a response
body:list[u8]
Bytes holding the body
headers:list[str]
List of headers
status:i32
Status code, 200, 404, etc.
url:str=""
Final address after redirects
snd
Low-level audio library
buffer_full():i32
Check if audio buffer is full
PARAMETERS
RETURNS
i321 if full, 0 otherwise
exit():void
Uninitialize library and release resources
PARAMETERS
RETURNS
void
init(rate:i32,chan:i32):void
Initialize the library. Required before calling any other functions from the library.
PARAMETERS
ratei32sampling rate, e.g. 44100
chani32number of channels, 1=mono, 2=stereo
RETURNS
void
put_sample(x:f32):void
Put an audio sample onto the audio buffer to be played
PARAMETERS
xf32audio sample (-1.0 to 1.0)
RETURNS
void
str
Immutable sequence of characters
chr(i:u32):str
Create a string holding 1 character given a code point
PARAMETERS
iu32code point
RETURNS
strstring holding the character specified by the code point
decode(btyes:list[u8],encoding:str):str
Decode a list of bytes into a string using given encoding
PARAMETERS
btyeslist[u8]list of bytes holding the encoded representation
encodingstrencoding, e.g. utf-8, ascii
RETURNS
strdecoded string
encode(s:str,encoding:str):list[u8]
Encode a string into a list of bytes using given encoding
PARAMETERS
sstrthe string to be encoded
encodingstrencoding, e.g. utf-8, ascii
RETURNS
list[u8]encoded list of bytes
length(s:str):i32
Retrieve length of a string
PARAMETERS
sstrthe string to query
RETURNS
i32number of characters in the string
ord(s:str):u32
Find code point of a character
PARAMETERS
sstrstring containing the 1 character
RETURNS
u32the code point
time
Library for time-related functions
delay(ms:f32):void
Pause the program for given milliseconds
PARAMETERS
msf32time in milliseconds
RETURNS
void
fps(trg:f32):f32
Set target frame rate for a program by calling this function once every iteration of the main loop.
PARAMETERS
trgf32desired frames-per-second
RETURNS
f32current frame rate
fps():f32
Retrieve the current number of frames-per-second
PARAMETERS
RETURNS
f32current frame rate
local(stmp:f64):tup[i32,i32,i32,i32,i32,i32]
Interpret a Unix timestamp as local time
PARAMETERS
stmpf64timestamp in seconds
RETURNS
tup[i32,i32,i32,i32,i32,i32]year, month, day, hour, minute, second
local():tup[i32,i32,i32,i32,i32,i32]
Retrieve the current local time
PARAMETERS
RETURNS
tup[i32,i32,i32,i32,i32,i32]year, month, day, hour, minute, second
millis():f64
The number of milliseconds passed since program execution started
PARAMETERS
RETURNS
f64milliseconds
stamp():f64
Current Unix timestamp
PARAMETERS
RETURNS
f64timestamp in seconds
vec
Primitive type for homogeneous, multidimensional, immutable collection of numbers
cross(v:vec[f32,3],u:vec[f32,3]):vec[f32,3]
Vector cross product
PARAMETERS
vvec[f32,3]first vector
uvec[f32,3]second vector
RETURNS
vec[f32,3]the cross product
dir[N](v:vec[f32,N]):vec[f32,N]
Find unit vector holding the direction of a given vector
PARAMETERS
vvec[f32,N]vector in question
RETURNS
vec[f32,N]normalized copy
dot[N](v:vec[f32,N],u:vec[f32,N]):f32
Vector dot product
PARAMETERS
vvec[f32,N]first vector
uvec[f32,N]second vector
RETURNS
f32the dot product
mag[N](v:vec[f32,N]):f32
Find the L2 norm of a vector
PARAMETERS
vvec[f32,N]vector in question
RETURNS
f32the magnitude
vin
Library for video input (webcam/file)
create(flag:i32,path:str):Video
Create a video source from webcam or file
PARAMETERS
flagi32flags (e.g. source, resolution, effects)
pathstrwebcam device name/file path 
RETURNS
Videothe video object
create(flag:i32):Video
Create a webcam capture with default device
PARAMETERS
flagi32flags (e.g. source, resolution, effects)
RETURNS
Videothe video object
EFFECT_MIRROR:i32=64
Flag for applying horizontal flip
RESO_FHD:i32=32
Flag for full HD resolution (1920x1080)
RESO_HD:i32=16
Flag for HD resolution (1280x720)
RESO_VGA:i32=8
Flag for VGA resolution (640x480)
SOURCE_FILE:i32=2
Flag for reading from a file
SOURCE_WEBCAM:i32=1
Flag for reading from a webcam
Videotype
Datatype holding a video object
h:i32
Frame height in pixels
id:i32
Internal ID/handler of the video
read_pixels():arr[u8,3]
Read pixel colors of the current frame into an array and advance to the next frame
PARAMETERS
RETURNS
arr[u8,3]pixels, RGBA 0-255
w:i32
Frame width in pixels
win
The windowing library
CONTEXT_2D:i32=1
Flag for attaching a 2D context
CONTEXT_3D:i32=2
Flag for attaching a 3D context
Eventtype
Datatype holding a user event
key:i32
Key code / mouse button
type:i32
Event type (e.g. keypress, mouse release)
x:f32
Coordinate X
y:f32
Coordinate Y
exit():void
Close the window and release the resources
PARAMETERS
RETURNS
void
IDLE:i32=0
Event type for no event
init(w:i32,h:i32,flags:i32):u64
Create a window. Required before calling any other functions from the library.
PARAMETERS
wi32width
hi32height
flagsi32flags (e.g. 2D/3D context)
RETURNS
u64a context ID/handler
KEY_DARR:i32=0xff54
Key code for down arrow
KEY_F1:f32=0xffbe
Key code for function key F1
KEY_F10:i32=0xffc7
Key code for function key F10
KEY_F11:i32=0xffc8
Key code for function key F11
KEY_F12:i32=0xffc9
Key code for function key F12
KEY_F2:i32=0xffbf
Key code for function key F2
KEY_F3:i32=0xffc0
Key code for function key F3
KEY_F4:i32=0xffc1
Key code for function key F4
KEY_F5:i32=0xffc2
Key code for function key F5
KEY_F6:i32=0xffc3
Key code for function key F6
KEY_F7:i32=0xffc4
Key code for function key F7
KEY_F8:i32=0xffc5
Key code for function key F8
KEY_F9:i32=0xffc6
Key code for function key F9
KEY_LALT:f32=0xffe9
Key code for left alt (option)
KEY_LARR:i32=0xff51
Key code for left arrow
KEY_LCMD:f32=0xffeb
Key code for left command (meta)
KEY_LCTRL:f32=0xffe3
Key code for left control
KEY_LSHIFT:f32=0xffe1
Key code for left shift
KEY_PRESSED:i32=4
Event type for key down
KEY_RALT:f32=0xffea
Key code for right alt (option
KEY_RARR:i32=0xff53
Key code for right arrow
KEY_RCMD:f32=0xffec
Key code for right command (meta)
KEY_RCTRL:f32=0xffe4
Key code for right control
KEY_RELEASED:i32=5
Event type for key up
KEY_RSHIFT:f32=0xffe2
Key code for right shift
KEY_UARR:i32=0xff52
Key code for up arrow
MOUSE_LEFT:i32=1
Button code for left mouse button
MOUSE_MOVED:i32=3
Event type for mouse move
MOUSE_PRESSED:i32=1
Event type for mouse down
MOUSE_RELEASED:i32=2
Event type for mouse up
MOUSE_RIGHT:i32=2
Button code for right mouse button
poll():Event
Listen for user event (non-blocking)
PARAMETERS
RETURNS
Eventan event