readouts
`require("crashReadouts.readouts")`: the pure display half of crashReadouts. It turns a crash test's `CrashResult` into a widget tree in one of eight styles, and ships the drawing helpers those styles are made of. Nothing here measures or derives a crash number; it formats what t…
readouts
require("crashReadouts.readouts"): the pure display half of crashReadouts. It turns a crash test's
CrashResult into a widget tree in one of eight styles, and ships the drawing helpers those styles
are made of. Nothing here measures or derives a crash number; it formats what the result holds.
Readouts.styles():{ { id, name, description, tags } }for the 8 styles.Readouts.render(style, result, { w, h, t?, points? }): widget tree sizedw × h.tis seconds since shown and drives the entrance (rows cascading, traces sweeping in, the stamp landing). Leave it out for the settled look.points = { car = {x,y,visible}, head = {x,y,visible} }places thefloatinglabels (UI canvas points).Readouts.layout(style, screenW, screenH, anchor?): where a style wants to sit:{ x, y, w, h, sheet?, full? }.Readouts.sample(opts?): a believable CrashResult with traces (speedKmh,car,dummy,belt,obstacle).Readouts.rows(result): the readouts as{ key, label, short, value, unit }rows, already formatted.- Helpers other UIs can reuse:
traceSvg(result, opts)(grid + polylines + glow + peak cursors + axis labels),sevenSegSvg(text, opts)(seven-segment digits with ghost segments),starsSvg(n, opts),bodySvg(result, opts)(occupant silhouette coloured by rating).
Called by the ReadoutPanel component in the same package, and by any screen that wants to embed a
readout as a child node.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2crashReadouts.readouts — pure display of a crash-test `CrashResult`. local Readouts = require("crashReadouts.readouts") local tree = Readouts.render("oscilloscope", result, { w = 420, h = 620, t = 0.8 }) Every style is a pure function of (result, size, time-since-shown). Nothing here measures or derives a crash number: it formats what the CrashResult holds (see /source/design/SPEC.md, crashRig). `t` drives the entrance (rows cascading, traces sweeping in, the stamp slamming down); leave it out for the settled look.
num(v: any) → number
| arg | type | description |
|---|---|---|
| v | any |
has(v: any) → boolean
| arg | type | description |
|---|---|---|
| v | any |
f0(v: any) → string
| arg | type | description |
|---|---|---|
| v | any |
f1(v: any) → string
| arg | type | description |
|---|---|---|
| v | any |
cm(v: any) → string
| arg | type | description |
|---|---|---|
| v | any |
clamp01(x: number) → number
| arg | type | description |
|---|---|---|
| x | number |
ap(t: number, delay: number, dur: number) → number
0..1 progress of an entrance that starts at `delay` and lasts `dur`, eased out.
| arg | type | description |
|---|---|---|
| t | number | |
| delay | number | |
| dur | number |
lin(t: number, delay: number, dur: number) → number
| arg | type | description |
|---|---|---|
| t | number | |
| delay | number | |
| dur | number |
merge(a: any, b: any) → any
| arg | type | description |
|---|---|---|
| a | any | |
| b | any |
fx(p: number, dx: number?, dy: number?) → any
opacity + slide for an entrance progress p
| arg | type | description |
|---|---|---|
| p | number | |
| dx | number? | |
| dy | number? |
L(text: string, style: any?, id: string?) → any
| arg | type | description |
|---|---|---|
| text | string | |
| style | any? | |
| id | string? |
V(style: any, children: { any }) → any
| arg | type | description |
|---|---|---|
| style | any | |
| children | { any } |
Hz(style: any, children: { any }) → any
| arg | type | description |
|---|---|---|
| style | any | |
| children | { any } |
SVG(svg: string, w: number, h: number, extra: any?) → any
| arg | type | description |
|---|---|---|
| svg | string | |
| w | number | |
| h | number | |
| extra | any? |
scroll(style: any, children: { any }, outer: any?, innerW: number?) → any
| arg | type | description |
|---|---|---|
| style | any | |
| children | { any } | |
| outer | any? | |
| innerW | number? |
upper(s: any) → string
| arg | type | description |
|---|---|---|
| s | any |
grade(g: any) → void
| arg | type | description |
|---|---|---|
| g | any |
stars(r: any) → number
| arg | type | description |
|---|---|---|
| r | any |
rating(r: any, key: string) → any
| arg | type | description |
|---|---|---|
| r | any | |
| key | string |
title(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
obstacleName(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
dummyName(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
beltName(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
testId(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
partsText(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
partsCount(r: any) → number
| arg | type | description |
|---|---|---|
| r | any |
note(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
isInvalid(r: any) → boolean
A run the rig flagged as broken (`invalid = true`): its numbers are shown, marked, and it gets no stars.
| arg | type | description |
|---|---|---|
| r | any |
invalidNote(r: any) → string
| arg | type | description |
|---|---|---|
| r | any |
barPal(fill: string, over: any?) → any
A barsKit palette in a readout's colours. `fill` is the bar; `over` replaces any other key (track, light, dark, glow, short).
| arg | type | description |
|---|---|---|
| fill | string | |
| over | any? |
gauge(look: string, view: any) → any
One barsKit look as a still gauge: no low-value pulse, no hit shake.
| arg | type | description |
|---|---|---|
| look | string | |
| view | any |
rows(result: any) →
The readouts every style shows, as display rows: { key, label, short, value, unit }.
| arg | type | description |
|---|---|---|
| result | any | A CrashResult. |
examples
for _, row in Readouts.rows(result) do print(row.label, row.value, row.unit) end
niceMax(v: number) → number
| arg | type | description |
|---|---|---|
| v | number |
series(r: any, key: string) → void
| arg | type | description |
|---|---|---|
| r | any | |
| key | string |
peakOf(s: { number }) → void
| arg | type | description |
|---|---|---|
| s | { number } |
traceSvg(result: any, o: any) → string
Draw `result.traces` as an SVG document: grid, one polyline per channel, optional glow, peak cursors and axis labels.
| arg | type | description |
|---|---|---|
| result | any | A CrashResult carrying `traces = { dt, head, chest, car }`. |
| o | any | Drawing options: w, h, channels, colors, widths, dashes, glow, cursors, labels, gridColor, divX, divY, reveal (0..1 sweep), font, labelColor, fontSize, padL/padR/padT/padB, bg, axisColor, gmax. |
examples
local s = Readouts.traceSvg(result, { w = 300, h = 120, colors = { head = "#0f0" } })px(i: number) → number return padL
| arg | type | description |
|---|---|---|
| i | number |
py(g: number) → number return padT
| arg | type | description |
|---|---|---|
| g | number |
hseg(x0: number, x1: number, yc: number, h2: number) → string
| arg | type | description |
|---|---|---|
| x0 | number | |
| x1 | number | |
| yc | number | |
| h2 | number |
vseg(xc: number, y0: number, y1: number, h2: number) → string
| arg | type | description |
|---|---|---|
| xc | number | |
| y0 | number | |
| y1 | number | |
| h2 | number |
segPolys(ox: number) → void
| arg | type | description |
|---|---|---|
| ox | number |
sevenSegSvg(text: string, o: any?) →
Render text as seven-segment LCD digits (0-9, '-', '.', a few letters), with dim "ghost" segments.
| arg | type | description |
|---|---|---|
| text | string | What to show, e.g. "56.0". |
| o | any? | { on = colour of lit segments, off = colour of ghost segments, cells = minimum digit cells (right-aligned) }. |
examples
local s, ar = Readouts.sevenSegSvg("452", { on = "#1c2414" }); -- svg widget width = height * arstarPoints(cx: number, cy: number, R: number, r: number) → string
| arg | type | description |
|---|---|---|
| cx | number | |
| cy | number | |
| R | number | |
| r | number |
starsSvg(n: number, o: any?) → string
Five stars, `n` of them filled, as an SVG string 5.5 units wide per unit high.
| arg | type | description |
|---|---|---|
| n | number | Filled stars 0..5. |
| o | any? | { on, off, stroke, reveal (0..1 pops stars in order) }. |
examples
local s = Readouts.starsSvg(4, { on = "#ffcc00", off = "#33415c" })bodySvg(result: any, o: any?) → string
A front-view occupant silhouette with head/neck, chest and legs filled in their rating colours.
| arg | type | description |
|---|---|---|
| result | any | A CrashResult (reads rating.head, rating.neck?, rating.chest, rating.legs? or rating.structure). |
| o | any? | { outline, limb (arm colour), bg }. |
examples
local s = Readouts.bodySvg(result, {})styles( ) →
List the available readout styles.
examples
for _, s in Readouts.styles() do print(s.id, s.name) end
labPrintout(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
printed(node: any) → any
| arg | type | description |
|---|---|---|
| node | any |
dash( ) → any
kv(k: string, v: string) → any
| arg | type | description |
|---|---|---|
| k | string | |
| v | string |
mini(key: string, name: string) → any
| arg | type | description |
|---|---|---|
| key | string | |
| name | string |
oscilloscope(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
meas(label: string, value: string, col: string) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | string | |
| col | string |
chip(txt: string, col: string) → any
| arg | type | description |
|---|---|---|
| txt | string | |
| col | string |
knob(label: string) → any
| arg | type | description |
|---|---|---|
| label | string |
lowerThird(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
stat(label: string, value: string, unit: string, bar: any?) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | string | |
| unit | string | |
| bar | any? |
meter(v: any, full: number, g: any) → any
barsKit thin-line gauges: the value against a fixed full scale, coloured by its rating.
| arg | type | description |
|---|---|---|
| v | any | |
| full | number | |
| g | any |
plain(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
card(label: string, value: string, unit: string, span: boolean?, detail: string?) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | string | |
| unit | string | |
| span | boolean? | |
| detail | string? |
pair(a: any, b: any) → any
| arg | type | description |
|---|---|---|
| a | any | |
| b | any |
lcd(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
seg(text: string, hgt: number, cells: number?) → any
| arg | type | description |
|---|---|---|
| text | string | |
| hgt | number | |
| cells | number? |
cell(label: string, value: string, unit: string, hgt: number) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | string | |
| unit | string | |
| hgt | number |
ann(txt: string, lit: boolean) → any
| arg | type | description |
|---|---|---|
| txt | string | |
| lit | boolean |
btn(txt: string, col: string) → any
| arg | type | description |
|---|---|---|
| txt | string | |
| col | string |
screw( ) → any
scifi(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
bracket(pos: any, bt: number, br: number, bb: number, bl: number) → any
| arg | type | description |
|---|---|---|
| pos | any | |
| bt | number | |
| br | number | |
| bb | number | |
| bl | number |
ring(label: string, value: number?, maxv: number, text: string, unit: string, g: any) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | number? | |
| maxv | number | |
| text | string | |
| unit | string | |
| g | any |
dataRow(k: string, v: string, idx: number) → any
| arg | type | description |
|---|---|---|
| k | string | |
| v | string | |
| idx | number |
stars(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
region(name: string, g: any, lines: { string }, idx: number) → any
| arg | type | description |
|---|---|---|
| name | string | |
| g | any | |
| lines | { string } | |
| idx | number |
mini(label: string, value: string, unit: string) → any
| arg | type | description |
|---|---|---|
| label | string | |
| value | string | |
| unit | string |
callout(lines: { { string } }, accent: string, w: number, extra: { any }?) → any
| arg | type | description |
|---|---|---|
| lines | { { string } } | |
| accent | string | |
| w | number | |
| extra | { any }? |
leader(dx: number, dy: number, col: string) → string
| arg | type | description |
|---|---|---|
| dx | number | |
| dy | number | |
| col | string |
floating(r: any, w: number, h: number, t: number, o: any) → void
| arg | type | description |
|---|---|---|
| r | any | |
| w | number | |
| h | number | |
| t | number | |
| o | any |
invalidTag( ) → any
ghostRow(caption: string, low: any, high: any, full: number, col: string) → any
barsKit ghost bar: the solid part is the lower figure, the lingering ghost reaches the higher one.
| arg | type | description |
|---|---|---|
| caption | string | |
| low | any | |
| high | any | |
| full | number | |
| col | string |
place(pt: any, lines: { { string } }, accent: string, side: number, delay: number, id: string, extra: { any }?) → void
| arg | type | description |
|---|---|---|
| pt | any | |
| lines | { { string } } | |
| accent | string | |
| side | number | |
| delay | number | |
| id | string | |
| extra | { any }? |
render(style: string, result: any, opts: Opts?) → any
Build the widget tree that shows `result` in one style.
| arg | type | description |
|---|---|---|
| style | string | A style id from `Readouts.styles()`; an unknown id falls back to "plain". |
| result | any | A CrashResult (shape in the crashRig contract). |
| opts | Opts? | { w, h = size in UI points; t = seconds since shown (drives the entrance; omit for the settled look); points = { car = {x,y,visible}, head = {x,y,visible} } screen points for "floating" }. |
examples
ui.registerScreen("res", Readouts.render("plain", Readouts.sample(), { w = 420, h = 600 }))layout(style: string, screenW: number, screenH: number, anchor: string?) → any
The size and place a style wants on a screen of the given size: about a third of a desktop screen beside the 3D view, a bottom sheet on a phone, a wide bar for the lower third, the whole screen for floating labels.
| arg | type | description |
|---|---|---|
| style | string | Style id. |
| screenW | number | UI canvas width (ui.screenSize().width or the safe area width). |
| screenH | number | UI canvas height. |
| anchor | string? | "topRight" | "topLeft" | "bottomRight" | "bottomLeft". |
examples
local box = Readouts.layout("plain", 1280, 720, "topRight")sample(opts: any?) → any
A believable sample CrashResult with traces, for demos and screenshots (hatchback, adult 50th, 3-point belt, rigid wall, 56 km/h by default).
| arg | type | description |
|---|---|---|
| opts | any? | { speedKmh?, car?, dummy?, belt?, obstacle?, id? } catalogue ids as in the SPEC. |
examples
local r = Readouts.sample({ speedKmh = 64 })peak(a: { number }) → number
| arg | type | description |
|---|---|---|
| a | { number } |
clip3(a: { number }) → number
| arg | type | description |
|---|---|---|
| a | { number } |
hic15(a: { number }) → number
| arg | type | description |
|---|---|---|
| a | { number } |
gradeFor(x: number, a: number, b: number, c: number) → string
| arg | type | description |
|---|---|---|
| x | number | |
| a | number | |
| b | number | |
| c | 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.