A first-person street canyon rendered at character resolution, fullscreen,
self-contained: index.html has zero external references and is built from
src/ by `node build.js`. Never edit index.html by hand.
Renderer is voxel-space (heightmap) raycasting, not a wall grid: each screen
COLUMN marches front-to-back keeping a running silhouette row, which gives
occlusion, varying building heights, cross-streets and the slot of sky
between rooftops for free.
- src/city.js endless deterministic heightmap; districts, lots, signs,
the walk, and a 192-candidate search for a start point
that opens inside a canyon on every seed
- src/weather_state.js one weather director: six presets on a seeded schedule
with weighted transitions. Every element reads rel(), which
is 1.0 under the preset the build was tuned as
- src/control.js arbitration, not replacement -- the autopilot never stops
running, the viewer's pose is cross-faded over it, and
letting go re-anchors to the nearest point on the route.
Keyboard, mouse-look, touch, gamepad; pitch slides the
horizon because at this resolution that IS pitch
- src/surfaces.js facade/floor/sky texture, puddles, wet reflection
- src/raycast.js the column march
- src/elements/ 38 ambient elements: rain, steam, fog, lightning, stars,
moon, aircraft, blimps, drones, searchlights, beacons,
crowds with clothing archetypes, traffic, a cat, food
stalls, litter, props, skybridges, cables, neon, holo,
signals, shop spill, and the optics passes
- tools/ headless.cjs renders a frame with no browser; topng.py
prints it; metrics.py measures it; domshim.cjs boots the
BUILT page under a fake DOM; flicker-rate.cjs and
lightning-rate.cjs are the photosensitivity gates
Verified: deterministic (byte-identical renders across processes), 252/252
domshim checks, flicker-rate PASS under all six skies, lightning-rate PASS
on the four skies that carry storms and NOT_APPLICABLE on the two that do not.
Not yet verified in a real browser: glyph legibility, bloom appearance,
on-screen colour, frame budget, and touch/gamepad on hardware.
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Render a headless CyberCity frame to a PNG, with the same bloom the canvas applies."""
|
|
import sys, json
|
|
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
|
|
|
CW, CH = 9, 16
|
|
FONT = ImageFont.truetype("/usr/share/fonts/liberation-mono-fonts/LiberationMono-Bold.ttf", 15)
|
|
|
|
def main(src, dst):
|
|
lines = open(src).read().split('\n')
|
|
assert lines[0].startswith('CCFRAME'), 'not a CCFRAME dump'
|
|
cols, rows = map(int, lines[1].split())
|
|
pal = [tuple(map(int, c.split(','))) for c in lines[2].split(' ', 1)[1].split()]
|
|
glyphs = json.loads(lines[3].split(' ', 1)[1])
|
|
im = Image.new('RGB', (cols * CW, rows * CH), (2, 3, 6))
|
|
d = ImageDraw.Draw(im)
|
|
lit = 0
|
|
for y in range(rows):
|
|
parts = lines[4 + y].split(' ')
|
|
for x in range(cols):
|
|
fld = parts[x].split(',') # CCFRAME 2 appends a kind byte; ignore it here
|
|
ch, ci, lu = int(fld[0]), int(fld[1]), int(fld[2])
|
|
if ch == 0 or lu == 0: continue
|
|
r, g, b = pal[ci % len(pal)]
|
|
k = lu / 255.0
|
|
d.text((x * CW, y * CH), glyphs[ch], font=FONT,
|
|
fill=(int(r * k), int(g * k), int(b * k)))
|
|
lit += 1
|
|
g1 = im.filter(ImageFilter.GaussianBlur(1.5))
|
|
g2 = im.filter(ImageFilter.GaussianBlur(5.0))
|
|
glow = Image.blend(g1, g2, 0.5)
|
|
im = Image.blend(im, Image.eval(glow, lambda v: min(255, int(v * 2.0))), 0.5)
|
|
im.save(dst)
|
|
print(f"{dst} {cols}x{rows} cells {lit/(cols*rows)*100:.1f}% lit")
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1], sys.argv[2])
|