fumo:draw
Drawing records native commands during render. The completed command list
is immutable and remains visible until that script submits a newer frame,
which avoids flicker when the JavaScript lane skips a Present.
import { events } from "fumo:events";
import { draw, Color } from "fumo:draw";
events.on("render", ({ displaySize }) => {
const accent = Color.rgba(45, 170, 255, 220);
draw.line(12, 12, displaySize.width - 12, 12, accent, 2);
draw.rectFilled(24, 32, 140, 42, Color.rgba(10, 14, 20, 180), 5);
draw.text(36, 44, "FumoEngine", Color.white, 14, true);
});
Implemented primitives:
line, rect, rectFilled
circle, circleFilled
text
polyline, polygon, polygonFilled
triangle, triangleFilled
rectGradient
pushClipRect, popClipRect
image
Point collections accept [[x, y], ...], {x, y} objects, or a flat
coordinate array. draw.image accepts only a texture handle loaded by the
same package.
draw.worldToScreen({x, y, z}) and draw.worldToScreen(x, y, z) return a
copied {x, y} or null when projection is unavailable or behind the view.
Colors use packed 0xRRGGBBAA values. Color.rgba(r, g, b, a) creates one;
Color.white and Color.black are predefined.
Draw calls outside a render callback throw. Per-frame command and point
limits prevent one package from exhausting the renderer.