API Reference
mewnala
ALT = 342
module-attribute
BACKQUOTE = 96
module-attribute
BACKSLASH = 92
module-attribute
BACKSPACE = 259
module-attribute
BEVEL = 2
module-attribute
BRACKET_LEFT = 91
module-attribute
BRACKET_RIGHT = 93
module-attribute
CENTER = 1
module-attribute
CHORD = 1
module-attribute
CLOSE = True
module-attribute
COMMA = 44
module-attribute
CONTROL = 341
module-attribute
CORNER = 0
module-attribute
CORNERS = 1
module-attribute
DELETE = 261
module-attribute
DOWN = 264
module-attribute
END = 269
module-attribute
ENTER = 257
module-attribute
EQUAL = 61
module-attribute
ESCAPE = 256
module-attribute
F1 = 290
module-attribute
F10 = 299
module-attribute
F11 = 300
module-attribute
F12 = 301
module-attribute
F2 = 291
module-attribute
F3 = 292
module-attribute
F4 = 293
module-attribute
F5 = 294
module-attribute
F6 = 295
module-attribute
F7 = 296
module-attribute
F8 = 297
module-attribute
F9 = 298
module-attribute
HOME = 268
module-attribute
HSL = 2
module-attribute
HSV = 3
module-attribute
HWB = 4
module-attribute
INSERT = 260
module-attribute
KEY_0 = 48
module-attribute
KEY_1 = 49
module-attribute
KEY_2 = 50
module-attribute
KEY_3 = 51
module-attribute
KEY_4 = 52
module-attribute
KEY_5 = 53
module-attribute
KEY_6 = 54
module-attribute
KEY_7 = 55
module-attribute
KEY_8 = 56
module-attribute
KEY_9 = 57
module-attribute
KEY_A = 65
module-attribute
KEY_B = 66
module-attribute
KEY_C = 67
module-attribute
KEY_D = 68
module-attribute
KEY_E = 69
module-attribute
KEY_F = 70
module-attribute
KEY_G = 71
module-attribute
KEY_H = 72
module-attribute
KEY_I = 73
module-attribute
KEY_J = 74
module-attribute
KEY_K = 75
module-attribute
KEY_L = 76
module-attribute
KEY_M = 77
module-attribute
KEY_N = 78
module-attribute
KEY_O = 79
module-attribute
KEY_P = 80
module-attribute
KEY_Q = 81
module-attribute
KEY_R = 82
module-attribute
KEY_S = 83
module-attribute
KEY_T = 84
module-attribute
KEY_U = 85
module-attribute
KEY_V = 86
module-attribute
KEY_W = 87
module-attribute
KEY_X = 88
module-attribute
KEY_Y = 89
module-attribute
KEY_Z = 90
module-attribute
LAB = 7
module-attribute
LCH = 8
module-attribute
LEFT = 0
module-attribute
LEFT_ARROW = 263
module-attribute
LINEAR = 1
module-attribute
LINES = 2
module-attribute
MINUS = 45
module-attribute
MITER = 1
module-attribute
OKLAB = 5
module-attribute
OKLCH = 6
module-attribute
OPEN = 0
module-attribute
PAGE_DOWN = 267
module-attribute
PAGE_UP = 266
module-attribute
PERIOD = 46
module-attribute
PIE = 2
module-attribute
POINTS = 1
module-attribute
POLYGON = 0
module-attribute
PROJECT = 2
module-attribute
QUADS = 6
module-attribute
QUAD_STRIP = 7
module-attribute
QUOTE = 39
module-attribute
RADIUS = 3
module-attribute
RIGHT = 2
module-attribute
RIGHT_ARROW = 262
module-attribute
ROUND = 0
module-attribute
SEMICOLON = 59
module-attribute
SHIFT = 340
module-attribute
SLASH = 47
module-attribute
SPACE = 32
module-attribute
SQUARE = 1
module-attribute
SRGB = 0
module-attribute
SUPER = 343
module-attribute
TAB = 258
module-attribute
TRIANGLES = 3
module-attribute
TRIANGLE_FAN = 4
module-attribute
TRIANGLE_STRIP = 5
module-attribute
UP = 265
module-attribute
XYZ = 9
module-attribute
Attribute
named typed attribute. use the position()/color()/etc. classmethods for
builtins or Attribute(name, format) for custom ones.
format
property
name
property
color()
staticmethod
dead()
staticmethod
normal()
staticmethod
position()
staticmethod
rotation()
staticmethod
scale()
staticmethod
uv()
staticmethod
AttributeFormat
Float
instance-attribute
Float2
instance-attribute
Float3
instance-attribute
Float4
instance-attribute
BlendMode
DST_ALPHA = 8
class-attribute
instance-attribute
DST_COLOR = 6
class-attribute
instance-attribute
ONE = 1
class-attribute
instance-attribute
ONE_MINUS_DST_ALPHA = 9
class-attribute
instance-attribute
ONE_MINUS_DST_COLOR = 7
class-attribute
instance-attribute
ONE_MINUS_SRC_ALPHA = 5
class-attribute
instance-attribute
ONE_MINUS_SRC_COLOR = 3
class-attribute
instance-attribute
OP_ADD = 0
class-attribute
instance-attribute
OP_MAX = 4
class-attribute
instance-attribute
OP_MIN = 3
class-attribute
instance-attribute
OP_REVERSE_SUBTRACT = 2
class-attribute
instance-attribute
OP_SUBTRACT = 1
class-attribute
instance-attribute
SRC_ALPHA = 4
class-attribute
instance-attribute
SRC_ALPHA_SATURATED = 10
class-attribute
instance-attribute
SRC_COLOR = 2
class-attribute
instance-attribute
ZERO = 0
class-attribute
instance-attribute
Buffer
read()
write(values)
Color
a
property
writable
b
property
writable
g
property
writable
r
property
writable
darker(amount)
distance(other)
distance_squared(other)
gray(lightness)
staticmethod
hex(s)
staticmethod
hsla(h, s, l, a=1.0)
staticmethod
hsva(h, s, v, a=1.0)
staticmethod
hue()
hwba(h, w, b, a=1.0)
staticmethod
is_fully_opaque()
is_fully_transparent()
lab(l, a_axis, b_axis, alpha=1.0)
staticmethod
lch(l, c, h, a=1.0)
staticmethod
lerp(other, t)
lighter(amount)
linear(r, g, b, a=1.0)
staticmethod
luminance()
mix(other, t)
oklab(l, a_axis, b_axis, alpha=1.0)
staticmethod
oklch(l, c, h, a=1.0)
staticmethod
rotate_hue(degrees)
saturation()
srgb(r, g, b, a=1.0)
staticmethod
to_hex()
to_hsla()
to_hsva()
to_hwba()
to_lab()
to_lch()
to_linear()
to_list()
to_oklab()
to_oklch()
to_srgba()
to_tuple()
to_vec3()
to_vec4()
to_xyz()
with_alpha(a)
with_hue(hue)
with_luminance(value)
with_saturation(saturation)
xyz(x, y, z, a=1.0)
staticmethod
Compute
dispatch(x, y, z)
set(**kwargs)
Geometry
box(width, height, depth)
staticmethod
color(*args)
grid(nx, ny, nz, spacing=1.0)
staticmethod
lattice centered at the origin; topology is PointList, intended as a
position source for Particles(geometry=...) rather than rasterized.
index(i)
normal(*args)
set_vertex(i, *args)
sphere(radius, sectors=32, stacks=18)
staticmethod
uv(*args)
vertex(*args)
vertex_count()
Gltf
camera(index)
geometry(name)
light(index)
material(name)
material_names()
mesh_names()
Graphics
focused
property
height
property
key
property
key_code
property
key_is_pressed
property
mouse_button
property
mouse_is_pressed
property
mouse_wheel
property
mouse_x
property
mouse_y
property
moved_x
property
moved_y
property
pixel_density
property
pixel_height
property
pixel_width
property
pmouse_x
property
pmouse_y
property
width
property
arc(cx, cy, w, h, start, stop, mode)
background(*args)
background_image(image)
begin_contour()
begin_draw()
begin_shape(kind)
bezier(x1, y1, x2, y2, x3, y3, x4, y4)
bezier_vertex(cx1, cy1, cx2, cy2, x, y)
blend_mode(mode)
camera_center(*args)
camera_distance(distance)
camera_look_at(*args)
camera_max_distance(max)
camera_min_distance(min)
camera_position(*args)
camera_reset()
camera_speed(speed)
circle(cx, cy, d)
color(*args)
color_mode(mode, max1=None, max2=None, max3=None, max_alpha=None)
create_image(width, height)
curve(x1, y1, x2, y2, x3, y3, x4, y4)
curve_vertex(x, y)
disable_camera()
draw_box(width, height, depth)
draw_capsule(radius, length, detail)
draw_cone(radius, height, detail)
draw_conical_frustum(radius_top, radius_bottom, height, detail)
draw_cylinder(radius, height, detail)
draw_geometry(geometry)
draw_plane(width, height)
draw_sphere(radius, sectors, stacks)
draw_tetrahedron(radius)
draw_torus(radius, tube_radius, major_segments, minor_segments)
ellipse(cx, cy, w, h)
ellipse_mode(mode)
emissive(*args)
end_contour()
end_draw()
end_shape(close)
fill(*args)
flush()
free_camera()
image(source, dx, dy, d_width=None, d_height=None, sx=None, sy=None, s_width=None, s_height=None)
Draws an image to the screen.
Optional d_width and d_height resize the image on screen. If omitted,
the image's original dimensions are used.
Optional sx, sy, s_width, and s_height define a sub-region
of the source image to draw, specified in pixels.
Affected by image_mode(), tint(), and the current transform.
image_mode(mode)
Changes how image position arguments are interpreted.
CORNER(default) —dx,dyis the top-left corner.CORNERS—dx,dyandd_width,d_heightare opposite corners.CENTER—dx,dyis the center of the image.
light_directional(color, illuminance)
light_point(color, intensity, range, radius)
light_spot(color, intensity, range, radius, inner_angle, outer_angle)
line(x1, y1, x2, y2)
load_image(file)
Loads an image from a file and returns an Image object.
The path is relative to the sketch's assets directory.
metallic(value)
mode_2d()
mode_3d()
new_offscreen(width, height, asset_path, log_level)
staticmethod
no_fill()
no_stroke()
no_tint()
Removes the current tint color so images draw without color modification.
orbit_camera()
ortho(left, right, bottom, top, near, far)
pan_camera()
particles(particles, geometry)
perspective(fov, aspect, near, far)
point(x, y)
poll_for_sketch_update()
pop_matrix()
present()
push_matrix()
quad(x1, y1, x2, y2, x3, y3, x4, y4)
quadratic_vertex(cx, cy, x, y)
readback_png()
rect(x, y, w, h, tl, tr, br, bl)
rect_mode(mode)
reset_matrix()
rotate(angle)
rotate_x(angle)
rotate_y(angle)
rotate_z(angle)
roughness(value)
scale(*args)
set_material(material)
shear_x(angle)
shear_y(angle)
square(x, y, s)
stroke(*args)
stroke_cap(cap)
stroke_join(join)
stroke_weight(weight)
tint(*args)
Sets a tint color applied when drawing images.
Accepts the same color arguments as fill(). The tint is multiplied
with the image's pixel colors. Use no_tint() to remove.
translate(*args)
triangle(x1, y1, x2, y2, x3, y3)
unlit()
use_material(material)
vertex(x, y)
Image
Light
look_at(*args)
position(*args)
Material
pbr(**kwargs)
staticmethod
set(**kwargs)
unlit(**kwargs)
staticmethod
Monitor
height
property
name
property
position
property
refresh_rate_millihertz
property
scale_factor
property
width
property
workarea
property
Particles
capacity
property
apply(compute, **kwargs)
dispatch a compute kernel against these particles' buffers. buffers are
auto-bound by attribute name; kwargs are forwarded to compute.set(...).
buffer(attribute)
backing Buffer for a registered attribute, or None if not registered.
emit(n, **kwargs)
emit n particles into the next ring-buffer slots. per-attribute data
is a kwarg keyed by attribute name; each value is a flat list of
n * format.float_count() floats.
emit_gpu(n, compute)
emit n particles via a GPU kernel. auto-binds buffers and an
emit_range: vec4<f32> = (base_slot, n, capacity, 0) uniform.
Quat
dot(other)
from_axis_angle(axis, angle)
staticmethod
from_euler(x, y, z)
staticmethod
from_rotation_x(angle)
staticmethod
from_rotation_y(angle)
staticmethod
from_rotation_z(angle)
staticmethod
identity()
staticmethod
inverse()
length()
mul_vec3(v)
normalize()
slerp(other, t)
to_euler()
w(val)
x(val)
y(val)
z(val)
Sampler
Configures how an image is sampled when drawn.
Controls texture filtering and edge wrapping behavior.
filter—Sampler.LINEAR(smooth) orSampler.NEAREST(pixelated).wrap—Sampler.CLAMP(default),Sampler.REPEAT, orSampler.MIRROR. Usewrap_x/wrap_yto set each axis independently.
CLAMP = 0
class-attribute
instance-attribute
LINEAR = 0
class-attribute
instance-attribute
MIRROR = 2
class-attribute
instance-attribute
NEAREST = 1
class-attribute
instance-attribute
REPEAT = 1
class-attribute
instance-attribute
Shader
load(path)
staticmethod
Surface
display_density
property
focused
property
pixel_density
property
pixel_height
property
pixel_width
property
position
property
center_on(monitor)
focus()
hide()
iconify()
maximize()
poll_events()
position_on(monitor, x, y)
restore()
set_always_on_top(on_top)
set_decorated(decorated)
set_fullscreen(monitor=None)
set_opacity(opacity)
set_pixel_density(density)
set_position(x, y)
set_resizable(resizable)
set_title(title)
set_visible(visible)
show()
Topology
LineList
instance-attribute
LineStrip
instance-attribute
PointList
instance-attribute
TriangleList
instance-attribute
TriangleStrip
instance-attribute
Vec2
ONE
instance-attribute
X
instance-attribute
Y
instance-attribute
ZERO
instance-attribute
abs()
add(*args)
angle()
angle_between(v1, v2)
staticmethod
clamp(min, max)
copy()
dist(other)
distance(other)
div(n)
dot(other)
equals(other)
extend(z)
from_angle(angle)
staticmethod
hash_code()
heading()
length()
length_squared()
lerp(other, t)
limit(max)
mag()
mag_sq()
max(other)
min(other)
mult(n)
normalize()
perpendicular()
random()
staticmethod
rotate(angle)
set(*args)
set_heading(angle)
set_mag(len)
sub(*args)
to_list()
to_tuple()
x(val)
y(val)
Vec3
ONE
instance-attribute
X
instance-attribute
Y
instance-attribute
Z
instance-attribute
ZERO
instance-attribute
abs()
add(*args)
angle_between(v1, v2)
staticmethod
clamp(min, max)
copy()
cross(other)
dist(other)
distance(other)
div(n)
dot(other)
equals(other)
extend(w)
hash_code()
length()
length_squared()
lerp(other, t)
limit(max)
mag()
mag_sq()
max(other)
min(other)
mult(n)
normalize()
random()
staticmethod
set(*args)
set_mag(len)
sub(*args)
to_list()
to_tuple()
truncate()
x(val)
y(val)
z(val)
Vec4
ONE
instance-attribute
W
instance-attribute
X
instance-attribute
Y
instance-attribute
Z
instance-attribute
ZERO
instance-attribute
abs()
add(*args)
angle_between(v1, v2)
staticmethod
clamp(min, max)
copy()
dist(other)
distance(other)
div(n)
dot(other)
equals(other)
hash_code()
length()
length_squared()
lerp(other, t)
limit(max)
mag()
mag_sq()
max(other)
min(other)
mult(n)
normalize()
set(*args)
set_mag(len)
sub(*args)
to_list()
to_tuple()
truncate()
w(val)
x(val)
y(val)
z(val)
arc(cx, cy, w, h, start, stop, mode=0)
background(*args)
begin_contour()
begin_shape(kind=0)
bezier(x1, y1, x2, y2, x3, y3, x4, y4)
bezier_vertex(cx1, cy1, cx2, cy2, x, y)
blend_mode(mode)
camera_center(*args)
camera_distance(distance)
camera_look_at(*args)
camera_max_distance(max)
camera_min_distance(min)
camera_position(*args)
camera_reset()
camera_speed(speed)
circle(cx, cy, d)
color_hex(s)
color_mode(mode, max1=None, max2=None, max3=None, max_alpha=None)
create_color(*args)
create_image(width, height)
curve(x1, y1, x2, y2, x3, y3, x4, y4)
curve_vertex(x, y)
directional_light(color, illuminance, *, position=None, look_at=None)
disable_camera()
display_density()
draw_box(*args)
draw_capsule(radius, length, detail=24)
draw_cone(radius, height, detail=24)
draw_conical_frustum(radius_top, radius_bottom, height, detail=24)
draw_cylinder(radius, height, detail=24)
draw_geometry(geometry)
draw_plane(width, height)
draw_sphere(radius, sectors=32, stacks=18)
draw_tetrahedron(radius)
draw_torus(radius, tube_radius, major_segments=24, minor_segments=16)
ellipse(cx, cy, w, h)
ellipse_mode(mode)
emissive(*args)
end_contour()
end_shape(close=False)
fill(*args)
flush()
free_camera()
full_screen(monitor=None)
hsla(h, s, l, a=1.0)
hsva(h, s, v, a=1.0)
hwba(h, w, b, a=1.0)
image(source, dx, dy, d_width=None, d_height=None, sx=None, sy=None, s_width=None, s_height=None)
Draws an image to the screen.
Optional d_width/d_height resize on screen; defaults to the image's
original dimensions. Optional sx/sy/s_width/s_height select a
sub-region of the source image in pixels.
image_mode(mode)
Changes how image position arguments are interpreted.
CORNER(default) —dx,dyis the top-left corner.CENTER—dx,dyis the center.CORNERS—dx,dyandd_width,d_heightare opposite corners.
kernel_noise()
kernel_transform()
key_is_down(key_code)
key_just_pressed(key_code)
lab(l, a_axis, b_axis, alpha=1.0)
lch(l, c, h, a=1.0)
line(x1, y1, x2, y2)
linear_rgb(r, g, b, a=1.0)
load_gltf(path)
load_image(image_file)
Loads an image from a file and returns an Image object.
loop_()
metallic(value)
midi_connect(port)
midi_disconnect()
midi_list_ports()
midi_note_off(note)
midi_note_on(note, velocity)
midi_play_notes(note, duration)
midi_refresh_ports()
mode_2d()
mode_3d()
monitors()
no_fill()
no_loop()
no_stroke()
no_tint()
Removes the current tint so images draw without color modification.
oklab(l, a_axis, b_axis, alpha=1.0)
oklch(l, c, h, a=1.0)
orbit_camera()
pan_camera()
particles(particles, geometry)
pixel_density(density=None)
point(x, y)
point_light(color, intensity, range, radius, *, position=None, look_at=None)
pop_matrix()
primary_monitor()
push_matrix()
quad(x1, y1, x2, y2, x3, y3, x4, y4)
quadratic_vertex(cx, cy, x, y)
rect(*args)
rect_mode(mode)
redraw()
reset_matrix()
rotate(angle)
rotate_x(angle)
rotate_y(angle)
rotate_z(angle)
roughness(value)
run()
scale(*args)
shear_x(angle)
shear_y(angle)
size(width, height)
spot_light(color, intensity, range, radius, inner_angle, outer_angle, *, position=None, look_at=None)
square(x, y, s)
srgb(r, g, b, a=1.0)
stroke(*args)
stroke_cap(cap)
stroke_join(join)
stroke_weight(weight)
tint(*args)
Sets a tint color applied when drawing images.