Skip to content

API Reference

mewnala

VecIter = _native_math.PyVecIter 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)

Font

metadata()

Query font metadata.

Returns a (family, style, weight, width, is_variable) tuple.

variations()

Query variable font axes.

Returns a list of (tag, min, max, default) tuples.

Geometry

box(width, height, depth) staticmethod

color(*args)

grid(nx, ny, nz, spacing=1.0) staticmethod

lattice centered at the origin; topology is POINTS, 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)

clear()

clear_text_features()

clear_text_variations()

color(*args)

color_mode(mode, max1=None, max2=None, max3=None, max_alpha=None)

create_font(name)

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, dy is the top-left corner.
  • CORNERSdx, dy and d_width, d_height are opposite corners.
  • CENTERdx, dy is 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)

list_fonts()

load_font(path)

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_text_feature(tag)

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()

pop_matrix()

pop_style()

present()

push()

push_matrix()

push_style()

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_axis(angle, *args)

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)

text(content, x, y, *args, max_w=None, max_h=None)

text_align(h, v=None)

text_ascent()

text_bounds(content, x, y, max_w=None, max_h=None)

text_descent()

text_feature(tag, value=None)

Enable/configure an OpenType font feature. text_feature("smcp") -> enable (value=1) text_feature("smcp", True) -> enable (value=1) text_feature("smcp", False) -> disable (value=0) text_feature("salt", 3) -> select alternate 3

text_font(font=None)

text_glyph_colors(colors)

Set per-glyph colors for the next text() call.

colors is a list of color objects (as built by color(...)); they are cycled across the glyphs of the next text() call.

text_glyph_rects(content, x, y, max_w=None, max_h=None)

Per-glyph bounding rects as a list of (x, y, w, h) tuples.

text_leading(leading)

text_line_count(content)

Number of lines content wraps to.

text_lines(content, x, y, max_w=None, max_h=None)

Per-line info as a list of (text, (x, y, w, h)) tuples.

text_size(size)

text_style(style)

text_to_contours(content, x, y)

Extract glyph outlines as per-contour path commands. Each contour (MoveTo...Close sequence) is a separate list. Commands use the same tuple shapes as text_to_paths.

text_to_model(content, x, y, depth)

Generate a 3D extruded mesh from text outlines.

text_to_paths(content, x, y)

Extract glyph outlines as path commands (one list per glyph). Each command is a tuple: ("M", x, y), ("L", x, y), ("Q", cx, cy, x, y), ("C", cx1, cy1, cx2, cy2, x, y), or ("Z",).

text_to_points(content, x, y, sample_factor=None)

Sample points along text outlines. Returns list of [x, y] points.

text_variation(tag, value)

text_weight(weight)

text_width(content)

text_wrap(mode)

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

sampler(sampler)

Applies a Sampler to this image, controlling filtering and wrapping.

s = Sampler(filter=NEAREST, wrap=REPEAT)
img.sampler(s)

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

w property writable

x property writable

y property writable

z property writable

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()

Sampler

Configures how an image is sampled when drawn.

Controls texture filtering and edge wrapping behavior.

  • filterLINEAR (smooth, default) or NEAREST (pixelated).
  • wrapCLAMP (default), REPEAT, or MIRROR. Use wrap_x/wrap_y to set each axis independently.

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()

Vec2

ONE instance-attribute

X instance-attribute

Y instance-attribute

ZERO instance-attribute

x property writable

xx property

xxx property

xxxx property

xxxy property

xxy property

xxyx property

xxyy property

xy property

xyx property

xyxx property

xyxy property

xyy property

xyyx property

xyyy property

y property writable

yx property

yxx property

yxxx property

yxxy property

yxy property

yxyx property

yxyy property

yy property

yyx property

yyxx property

yyxy property

yyy property

yyyx property

yyyy property

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()

Vec3

ONE instance-attribute

X instance-attribute

Y instance-attribute

Z instance-attribute

ZERO instance-attribute

x property writable

xx property

xxx property

xxxx property

xxxy property

xxxz property

xxy property

xxyx property

xxyy property

xxyz property

xxz property

xxzx property

xxzy property

xxzz property

xy property

xyx property

xyxx property

xyxy property

xyxz property

xyy property

xyyx property

xyyy property

xyyz property

xyz property

xyzx property

xyzy property

xyzz property

xz property

xzx property

xzxx property

xzxy property

xzxz property

xzy property

xzyx property

xzyy property

xzyz property

xzz property

xzzx property

xzzy property

xzzz property

y property writable

yx property

yxx property

yxxx property

yxxy property

yxxz property

yxy property

yxyx property

yxyy property

yxyz property

yxz property

yxzx property

yxzy property

yxzz property

yy property

yyx property

yyxx property

yyxy property

yyxz property

yyy property

yyyx property

yyyy property

yyyz property

yyz property

yyzx property

yyzy property

yyzz property

yz property

yzx property

yzxx property

yzxy property

yzxz property

yzy property

yzyx property

yzyy property

yzyz property

yzz property

yzzx property

yzzy property

yzzz property

z property writable

zx property

zxx property

zxxx property

zxxy property

zxxz property

zxy property

zxyx property

zxyy property

zxyz property

zxz property

zxzx property

zxzy property

zxzz property

zy property

zyx property

zyxx property

zyxy property

zyxz property

zyy property

zyyx property

zyyy property

zyyz property

zyz property

zyzx property

zyzy property

zyzz property

zz property

zzx property

zzxx property

zzxy property

zzxz property

zzy property

zzyx property

zzyy property

zzyz property

zzz property

zzzx property

zzzy property

zzzz property

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()

Vec4

ONE instance-attribute

W instance-attribute

X instance-attribute

Y instance-attribute

Z instance-attribute

ZERO instance-attribute

w property writable

ww property

www property

wwww property

wwwx property

wwwy property

wwwz property

wwx property

wwxw property

wwxx property

wwxy property

wwxz property

wwy property

wwyw property

wwyx property

wwyy property

wwyz property

wwz property

wwzw property

wwzx property

wwzy property

wwzz property

wx property

wxw property

wxww property

wxwx property

wxwy property

wxwz property

wxx property

wxxw property

wxxx property

wxxy property

wxxz property

wxy property

wxyw property

wxyx property

wxyy property

wxyz property

wxz property

wxzw property

wxzx property

wxzy property

wxzz property

wy property

wyw property

wyww property

wywx property

wywy property

wywz property

wyx property

wyxw property

wyxx property

wyxy property

wyxz property

wyy property

wyyw property

wyyx property

wyyy property

wyyz property

wyz property

wyzw property

wyzx property

wyzy property

wyzz property

wz property

wzw property

wzww property

wzwx property

wzwy property

wzwz property

wzx property

wzxw property

wzxx property

wzxy property

wzxz property

wzy property

wzyw property

wzyx property

wzyy property

wzyz property

wzz property

wzzw property

wzzx property

wzzy property

wzzz property

x property writable

xw property

xww property

xwww property

xwwx property

xwwy property

xwwz property

xwx property

xwxw property

xwxx property

xwxy property

xwxz property

xwy property

xwyw property

xwyx property

xwyy property

xwyz property

xwz property

xwzw property

xwzx property

xwzy property

xwzz property

xx property

xxw property

xxww property

xxwx property

xxwy property

xxwz property

xxx property

xxxw property

xxxx property

xxxy property

xxxz property

xxy property

xxyw property

xxyx property

xxyy property

xxyz property

xxz property

xxzw property

xxzx property

xxzy property

xxzz property

xy property

xyw property

xyww property

xywx property

xywy property

xywz property

xyx property

xyxw property

xyxx property

xyxy property

xyxz property

xyy property

xyyw property

xyyx property

xyyy property

xyyz property

xyz property

xyzw property

xyzx property

xyzy property

xyzz property

xz property

xzw property

xzww property

xzwx property

xzwy property

xzwz property

xzx property

xzxw property

xzxx property

xzxy property

xzxz property

xzy property

xzyw property

xzyx property

xzyy property

xzyz property

xzz property

xzzw property

xzzx property

xzzy property

xzzz property

y property writable

yw property

yww property

ywww property

ywwx property

ywwy property

ywwz property

ywx property

ywxw property

ywxx property

ywxy property

ywxz property

ywy property

ywyw property

ywyx property

ywyy property

ywyz property

ywz property

ywzw property

ywzx property

ywzy property

ywzz property

yx property

yxw property

yxww property

yxwx property

yxwy property

yxwz property

yxx property

yxxw property

yxxx property

yxxy property

yxxz property

yxy property

yxyw property

yxyx property

yxyy property

yxyz property

yxz property

yxzw property

yxzx property

yxzy property

yxzz property

yy property

yyw property

yyww property

yywx property

yywy property

yywz property

yyx property

yyxw property

yyxx property

yyxy property

yyxz property

yyy property

yyyw property

yyyx property

yyyy property

yyyz property

yyz property

yyzw property

yyzx property

yyzy property

yyzz property

yz property

yzw property

yzww property

yzwx property

yzwy property

yzwz property

yzx property

yzxw property

yzxx property

yzxy property

yzxz property

yzy property

yzyw property

yzyx property

yzyy property

yzyz property

yzz property

yzzw property

yzzx property

yzzy property

yzzz property

z property writable

zw property

zww property

zwww property

zwwx property

zwwy property

zwwz property

zwx property

zwxw property

zwxx property

zwxy property

zwxz property

zwy property

zwyw property

zwyx property

zwyy property

zwyz property

zwz property

zwzw property

zwzx property

zwzy property

zwzz property

zx property

zxw property

zxww property

zxwx property

zxwy property

zxwz property

zxx property

zxxw property

zxxx property

zxxy property

zxxz property

zxy property

zxyw property

zxyx property

zxyy property

zxyz property

zxz property

zxzw property

zxzx property

zxzy property

zxzz property

zy property

zyw property

zyww property

zywx property

zywy property

zywz property

zyx property

zyxw property

zyxx property

zyxy property

zyxz property

zyy property

zyyw property

zyyx property

zyyy property

zyyz property

zyz property

zyzw property

zyzx property

zyzy property

zyzz property

zz property

zzw property

zzww property

zzwx property

zzwy property

zzwz property

zzx property

zzxw property

zzxx property

zzxy property

zzxz property

zzy property

zzyw property

zzyx property

zzyy property

zzyz property

zzz property

zzzw property

zzzx property

zzzy property

zzzz property

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()

acos(x)

arc(cx, cy, w, h, start, stop, mode=...)

asin(x)

background(*args)

begin_contour()

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)

clear()

color_hex(s)

color_mode(mode, max1=None, max2=None, max3=None, max_alpha=None)

constrain(value, low, high)

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()

dist(*args)

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)

exp(x)

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, dy is the top-left corner.
  • CENTERdx, dy is the center.
  • CORNERSdx, dy and d_width, d_height are 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)

lerp(start, stop, amt)

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.

log(x)

loop_()

mag(*args)

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.

norm(value, start, stop)

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()

pop_matrix()

pop_style()

pow(base, exponent)

primary_monitor()

push()

push_matrix()

push_style()

quad(x1, y1, x2, y2, x3, y3, x4, y4)

quadratic_vertex(cx, cy, x, y)

quat(*args)

rect(*args)

rect_mode(mode)

redraw()

remap(value, start1, stop1, start2, stop2, within_bounds=False)

reset_matrix()

rotate(angle)

rotate_axis(angle, *args)

rotate_x(angle)

rotate_y(angle)

rotate_z(angle)

roughness(value)

round(x)

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)

sq(x)

sqrt(x)

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.

translate(*args)

triangle(x1, y1, x2, y2, x3, y3)

unlit()

use_material(material)

vec2(*args)

vec3(*args)

vec4(*args)

vertex(x, y)

window_always_on_top(on_top)

window_center_on(monitor)

window_decorated(decorated)

window_iconify()

window_maximize()

window_move(x, y)

window_opacity(opacity)

window_position_on(monitor, x, y)

window_resizable(resizable)

window_resize(w, h)

window_restore()

window_title(title)

window_visible(visible)

xyz(x, y, z, a=1.0)