paint
<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->
paint
<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->TODO: describe this module.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2emberline.stages.paint — the raster kit the four stages are painted with. A parallax layer is one PixelCanvas the size of a small painting. Drawing it through the canvas handle would cost one FFI call per operation; instead the whole layer is composed here as a plain Luau array of palette indices and handed to `Pixel.create { pixels = ... }` in one go. A 500x240 layer paints in about four milliseconds this way. local P = require("emberline.stages.paint") local pal = P.palette({ { "sky", "#1b2029" }, { "lamp", "#ffb642" } }) local b = P.new(512, 240) b:rect(0, 0, 511, 60, pal.i.sky) canvasOpts.palette, canvasOpts.pixels = pal.entries, b.c Cell (0,0) is the BOTTOM-LEFT of the sheet and index 0 is empty. Empty is only transparent on a canvas built with renderMode = "mesh"; a "texture" canvas paints an empty cell opaque black, so every layer that shows what is behind it is a mesh and every fully-painted layer is a texture.
rowY(row: number) → number
world y of a sheet row, and back again
| arg | type | description |
|---|---|---|
| row | number |
yRow(y: number) → number
| arg | type | description |
|---|---|---|
| y | number |
layer(key: string, buf: any, opts: any?) → any
A layer descriptor with the shared geometry filled in. `over` is a Paint buffer; everything else the stage may override.
| arg | type | description |
|---|---|---|
| key | string | |
| buf | any | |
| opts | any? |
hex(s: string) → void
"#rrggbb" -> { r, g, b } in 0..1.
| arg | type | description |
|---|---|---|
| s | string |
mix(a: { number }, b: { number }, t: number) → void
| arg | type | description |
|---|---|---|
| a | { number } | |
| b | { number } | |
| t | number |
scale(c: { number }, f: number) → void
| arg | type | description |
|---|---|---|
| c | { number } | |
| f | number |
palette(list: { any }) → any
Build a palette from an ordered list of { name, "#rrggbb" } (or { name, {r,g,b} }). Returns the array form PixelCanvas wants plus a name -> index map, so drawing code names its colours and never counts positions.
| arg | type | description |
|---|---|---|
| list | { any } |
rng(seed: number) → void
Every stage paints identically on every boot: a skyline that reshuffles between two captures cannot be compared against itself.
| arg | type | description |
|---|---|---|
| seed | number |
new(w: number, h: number, fillIdx: number?) → any
| arg | type | description |
|---|---|---|
| w | number | |
| h | number | |
| fillIdx | number? |
set(self: any, x: number, y: number, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| x | number | |
| y | number | |
| i | number |
get(self: any, x: number, y: number) → number
| arg | type | description |
|---|---|---|
| self | any | |
| x | number | |
| y | number |
fill(self: any, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| i | number |
rect(self: any, x0: number, y0: number, x1: number, y1: number, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| i | number |
rectBehind(self: any, x0: number, y0: number, x1: number, y1: number, i: number) → void
Paint a rect only where the buffer is still empty — the way a layer behind another element is filled in without erasing it.
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| i | number |
hline(self: any, y: number, x0: number, x1: number, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| y | number | |
| x0 | number | |
| x1 | number | |
| i | number |
vline(self: any, x: number, y0: number, y1: number, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| x | number | |
| y0 | number | |
| y1 | number | |
| i | number |
line(self: any, x0: number, y0: number, x1: number, y1: number, i: number, thick: number?) → void
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| i | number | |
| thick | number? |
limbLine(self: any, x0: number, y0: number, x1: number, y1: number, i: number) → void
A thin limb: a line one or two pixels wide, which is what an arm is at crowd scale.
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| i | number |
lamp(b: any, x: number, y: number, opts: any) → void
A lamp: the bracket, the shade, the filament, and a halo that fades by dither instead of sitting there as a solid oval. Every stage hangs its own light off this, which is why it is here and not in one of them.
| arg | type | description |
|---|---|---|
| b | any | |
| x | number | |
| y | number | |
| opts | any |
ellipse(self: any, cx: number, cy: number, rx: number, ry: number, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| cx | number | |
| cy | number | |
| rx | number | |
| ry | number | |
| i | number |
ring(self: any, cx: number, cy: number, rx: number, ry: number, i: number, thick: number?) → void
A hollow ellipse `thick` pixels wide — arches, wheels, lantern rims.
| arg | type | description |
|---|---|---|
| self | any | |
| cx | number | |
| cy | number | |
| rx | number | |
| ry | number | |
| i | number | |
| thick | number? |
poly(self: any, pts: { { number } }, i: number) → void
| arg | type | description |
|---|---|---|
| self | any | |
| pts | { { number } } | |
| i | number |
vbands(self: any, x0: number, x1: number, y0: number, y1: number, stops: { any }) → void
A hard-banded vertical gradient: `stops` is { { t, idx }, ... } with t in 0..1 measured from y0 to y1. Bands, not a blend — this is pixel art.
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| x1 | number | |
| y0 | number | |
| y1 | number | |
| stops | { any } |
dither(self: any, x0: number, x1: number, y0: number, y1: number, a: number, b: number) → void
Ordered-dither a band from index `a` at the bottom to index `b` at the top. The 4x4 Bayer pattern is what makes a smog gradient read as painted rather than as a blur, and it costs nothing.
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| x1 | number | |
| y0 | number | |
| y1 | number | |
| a | number | |
| b | number |
scatter(self: any, x0: number, y0: number, x1: number, y1: number, i: number, density: number, rnd: () → void
Sprinkle `i` into a box at `density` (0..1) using the caller's rng, so a pass of grit, ash, rust or distant lit windows is repeatable.
| arg | type | description |
|---|---|---|
| self | any | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| i | number | |
| density | number | |
| rnd | ( |
outline(self: any, i: number) → void
Put a one-pixel rim of `i` around every painted cluster. Only worth running on a layer whose elements must separate from what is behind them.
| arg | type | description |
|---|---|---|
| self | any | |
| i | number |
swap(self: any, from: number, to: number) → void
Replace one index with another everywhere. Used to recolour a stamped element without redrawing it.
| arg | type | description |
|---|---|---|
| self | any | |
| from | number | |
| to | number |
stamp(self: any, other: any, dx: number, dy: number) → void
Stamp another buffer at (dx, dy), skipping its empty cells.
| arg | type | description |
|---|---|---|
| self | any | |
| other | any | |
| dx | number | |
| dy | number |
clone(self: any) → any
| arg | type | description |
|---|---|---|
| self | any |
shifted(self: any, dx: number) → any
Copy the buffer shifted horizontally, wrapping — the cheapest way to make a scrolling texture read as a loop across a handful of baked frames.
| arg | type | description |
|---|---|---|
| self | any | |
| dx | number |
isOpaque(self: any) → boolean
True when no cell is empty. A layer handed to a "texture" canvas must pass this, because an empty cell there paints black instead of nothing.
| arg | type | description |
|---|---|---|
| self | any |
skyline(b: any, opts: any) → void
Kessai is built out of the same half-dozen industrial shapes over and over, so they live here and each stage tints and proportions them differently. A run of blocky towers along the bottom of a layer, tallest in the middle of each cluster. Returns the height profile so the caller can hang haze, chimneys or a viaduct off the same skyline.
| arg | type | description |
|---|---|---|
| b | any | |
| opts | any |
truss(b: any, x0: number, x1: number, y: number, depth: number, i: number, cell: number?) → void
A lattice girder between two points: two chords and a zig-zag web. Every canopy, gantry and crane in Kessai is made of these.
| arg | type | description |
|---|---|---|
| b | any | |
| x0 | number | |
| x1 | number | |
| y | number | |
| depth | number | |
| i | number | |
| cell | number? |
rivets(b: any, x0: number, x1: number, y: number, step: number, i: number) → void
A row of rivets — the detail that turns a flat plate into iron.
| arg | type | description |
|---|---|---|
| b | any | |
| x0 | number | |
| x1 | number | |
| y | number | |
| step | number | |
| i | number |
arch(b: any, cx: number, base: number, halfW: number, rise: number, thick: number, i: number) → void
A brick arch: the two piers and the semicircular head.
| arg | type | description |
|---|---|---|
| b | any | |
| cx | number | |
| base | number | |
| halfW | number | |
| rise | number | |
| thick | number | |
| i | number |
crowd(b: any, opts: any) → void
A crowd of small figures standing on `y`, drawn back to front so the rows overlap. `heads`/`bodies` are index arrays; the figures pick from them so the crowd is not one colour. Returns the figure list so an animated crowd can redraw the same people in a different pose.
| arg | type | description |
|---|---|---|
| b | any | |
| opts | any |
drawCrowd(b: any, people: { any }, lift: number, t: number, rim: number?) → void
Draw one crowd pose. `lift` raises the arms: 0 is standing, 1 is both arms over the head, which is what a knockout looks like from the barrier.
| arg | type | description |
|---|---|---|
| b | any | |
| people | { any } | |
| lift | number | |
| t | number | |
| rim | number? |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.