You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import('gui-draw-ops') provides a single draw() entry point that replaces
dozens of separate drawing functions with one composable, options-object-based
call. Instead of remembering which function handles which combination of
shape + fill + AA + lighting + dash style, you describe what you want once:
The old separate functions (drawCircle2D, drawCircleFilledAA,
drawMeshLit, etc.) remain available and unchanged. draw() delegates to
them internally based on the options you provide.
Draws a single primitive. op is an object with a required shape field plus
shape-specific geometry and optional effect modifiers.
drawBatch(window, ops)
Draws a list of op objects in sequence.
Shape Reference
Common Fields (all shapes)
Field
Type
Default
Description
shape
atom
required
Shape type (see below)
color
int
0 (black)
Fill/stroke color (packed RGB)
borderColor
int
?
Outline color
filled
bool
true
Fill the shape (vs outline only)
aa
bool
false
Enable anti-aliasing
bgColor
int
0
Background color for AA blending
:line
Field
Type
Default
Description
x1, y1
num
0
Start point
x2, y2
num
0
End point
thickness
num
?
Thick line width (>1 to activate)
dash
obj
?
{ len: 6, gap: 4 } for dashed
Priority: dash > thickness > aa > plain
:rect
Field
Type
Default
x, y
num
0
width, height
num
0
:circle
Field
Type
Default
cx, cy
num
0
r (or radius)
num
0
:ellipse
Field
Type
Default
cx, cy
num
0
rx, ry
num
0
:triangle
Two input modes:
Point objects:p0, p1, p2 — each { x, y }
Scalars:x1, y1, x2, y2, x3, y3
:roundedRect
Field
Type
Default
x, y
num
0
width, height
num
0
radius
num
4
:polygon
Field
Type
Default
points
list
[]
:polyline
Field
Type
Default
points
list
[]
closed
bool
false
:arc
Field
Type
Default
cx, cy
num
0
r (or radius)
num
0
startAngle
num
0
endAngle
num
360
:star
Field
Type
Default
cx, cy
num
0
outerR, innerR
num
0
points
int
5
:bezier
Field
Type
Default
points
list
[]
steps
int
? (auto)
:ring
Field
Type
Default
cx, cy
num
0
outerR, innerR
num
0
:cross
Field
Type
Default
cx, cy
num
0
size
num
0
thickness
num
2
:diamond
Field
Type
Default
cx, cy
num
0
width, height
num
0
:arrow
Field
Type
Default
x1, y1, x2, y2
num
0
headSize
num
? (auto)
:capsule
Field
Type
Default
cx, cy
num
0
width, height
num
0
:sector
Field
Type
Default
cx, cy
num
0
r (or radius)
num
0
startAngle, endAngle
num
0, 360
:regularPolygon
Field
Type
Default
cx, cy
num
0
r (or radius)
num
0
sides
int
6
:spiral
Field
Type
Default
cx, cy
num
0
startRadius
num
0
growth
num
1
turns
num
3
:grid
Field
Type
Default
spacing
num
32
originX, originY
num
0
:text
Field
Type
Default
x, y
num
0
text
string
''
:mesh (3D solid or lit)
Field
Type
Default
Description
mesh
obj
?
Mesh object (vertices, faces, edges)
transform
obj
?
{rx, ry, rz, scale, tx, ty, tz}
camera
obj
?
{z, fov, mode, orthoScale, ...}
light
obj
?
Simple directional light
lighting
obj
?
LightScene for Blinn-Phong (*)
material
obj
?
Material for lit rendering (*)
(*) When lighting is provided, the renderer uses drawMeshLit (full
Blinn-Phong multi-light). Otherwise it uses drawMeshSolid with the simple
light parameter.
:meshWire (3D wireframe)
Field
Type
Default
mesh
obj
?
transform
obj
?
camera
obj
?
How It Works
draw() is a thin dispatcher that reads op.shape and routes to the
appropriate existing drawing function, selecting the best variant based on
the effect flags present:
No new rendering code is added — the dispatcher composes the existing
primitives. The deps object is allocated once (lazily on first call) and
reused for all subsequent draw() calls.
Migration Guide
The old API remains fully functional. To adopt draw(), replace: