Geometry · function
forEachRun
Every horizontal run of lit cells, as one span each.
Explained in Hello world, Meshes and geometry.
function forEachRun(text: string, visit: (x: number, y: number, width: number, charIndex: number) => void): voidimport { forEachRun } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | |
visit | (x: number, y: number, width: number, charIndex: number) => void |
In depth
Because a box per cell is most of a world. A consumer measured their village at 2,662,324 triangles of which 1,195,296 — forty-five per cent — were the lettering on 169 street plates and 830 house numbers, one box of twelve triangles at each of 65,271 lit cells. A run of three lit cells side by side is three boxes with four interior faces between them that nothing can ever see, and one box the same shape outside.
Horizontal only, and that is a measurement rather than a simplification. Against that consumer's own 1,168 strings, merging runs takes 65,271 cells to 42,631 boxes, and a greedy rectangle merge over two dimensions gives exactly the same number — in a glyph five cells wide there is nothing vertical left to win, and the second pass would be code that never pays.
A run never crosses a glyph, because the cursor advances by GLYPH_WIDTH + GLYPH_SPACING and
that spacing is a column of unlit cells.