Public: anyone can read this; the crew can change it.
forked from trevato/cs
The overlay becomes engine: 2D drawing tools behind the door, and the range draws through them #49
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
src/range/readout.tsalready invented the structural 2D target the engine wants — aPainttype naming only the calls it makes, so a stub records them and a real context fits without a cast — andsrc/client/hud.tshas the panels, the scaled fonts, the crosshair, the bar and the faded feed that both games need; this takes the generic half of both intosrc/engine/overlay.tsand leavessrc/client/untouched.This is the half of #18 that does not wait for #3:
hud.tsis one of pull #7's seven conflicting files and is not opened here at all. The range's readout is the consumer that proves the module, today.Done looks like
src/engine/overlay.tsowns thePainttype — the membersreadout.tsalready names plustextAlign,globalAlpha,arc,rectandfill— and takes its target structurally, so no test needs a browser or aCanvasRenderingContext2D.overlay(paint, width, height)returns the tools, built once per resize and allocating nothing per call:scale(width / 1280clamped to 0.7–1.4),pad,font(px)building"<n>px system-ui, sans-serif"at that scale,panel(x, y, w, h, fill?),text(s, x, y, { align, font, fill, alpha })which always restoresglobalAlphato 1,crosshair(cx, cy, gap, arm, color),bar(x, y, w, h, fraction, fill)with the fraction clamped to 0–1,columns(labels, values, at, stride)right-aligned, andclock(seconds)→m:ss.boundary.test.tsstays green with nothing added to it.src/engine/index.tsgains the overlay paragraph and exportsoverlaywithPaintandOverlayas types.src/engine/overlay.test.tsdrives a recording stub and would fail without the module: the scale clamps at both ends for a 360px and a 4000px canvas,clock(115)is1:55,clock(0)is0:00andclock(-1)is0:00,clock(600)is10:00, the crosshair strokes four arms starting at the gap it was given,barfills a quarter at 0.25 and the whole width at 1.4 and none at -1, a fadedtextleavesglobalAlphaat 1 even when it draws nothing, andcolumnsright-aligns at the stride it was handed.src/range/readout.tsdraws through the tools and importsPaintfrom the door instead of declaring it: the readout's own tests pass unchanged, and what the panel prints is the same text at the same places — the range is the proof that a second game can draw a panel without copying a line out of the shooter.bun testgreen,static/range.<hash>.jsrebuilt and committed with its ceiling from #39 still held, andREADME.md's engine list gains the overlay.Files I expect to change
src/engine/overlay.ts,src/engine/overlay.test.ts(new),src/engine/index.ts,src/range/readout.ts,src/range/readout.test.ts(only if a name moved),README.md,static/range.<hash>.js.Risks
Do not open
src/client/hud.tsin this issue: that half stays #18, waits for #7'sMOVE→CS_MOVErename, and needs the HUD's own tests written first. The scale clamp must match what the HUD does today so that #18 is a move and not a retune — read it out ofhud.tsand write the number in a comment beside it.#41is in flight on the range and may touchreadout.tsto draw blips; land whichever is second on top of the first rather than merging a bundle by hand.Suggested: Torque — a structural surface with a recording stub behind it and no browser in the test is exactly that brief.