e-os-v6 / scripts /test_draw.py
KillerBoss's picture
E-OS v0.6: Liquid Glass — Formen rein, Glas+Wasser raus (NPU 3.11ms)
da43581 verified
Raw History Blame Contribute Delete
1.57 kB
# E-OS v6 — visual test of the liquid-glass renderer.
import sys, os, time
import numpy as np
sys.path.insert(0, os.path.dirname(__file__))
from os6_spec import *
from os6_draw import render_frame, rasterize_hint
from PIL import Image
rng = np.random.default_rng(42)
OUT = "/home/z/my-project/download/e-os-v6/eval"
os.makedirs(OUT, exist_ok=True)
t0 = time.time()
# 4 themes x home layout, one with a big ripple
rows = []
for th in range(4):
sh = lay_home(rng)
rip = (0.5, 0.55, 0.30) if th % 2 == 0 else (0.3, 0.35, 0.55)
fr = render_frame(sh, th, 0.45, 0.25, [rip], pressed=1, seed=th)
rows.append(fr)
dt = time.time() - t0
print("4 frames in %.2fs (%.0f ms/frame)" % (dt, dt / 4 * 1000))
grid = np.concatenate(rows, axis=1)
Image.fromarray(grid).save(os.path.join(OUT, "os6_glass_preview.png"))
# random layout + early/late ripple + day phases
sh = lay_random(rng)
frames = []
for (day, sh_t, rip) in [(0.5, 0.1, (0.35, 0.5, 0.12)), (0.95, 0.5, (0.6, 0.7, 0.45)),
(0.2, 0.9, (0.75, 0.3, 0.75)), (0.5, 0.5, (0, 0, -1))]:
frames.append(render_frame(sh, 2, day, sh_t, [rip] if rip[2] >= 0 else [], seed=7))
Image.fromarray(np.concatenate(frames, axis=1)).save(
os.path.join(OUT, "os6_variants_preview.png"))
# hint check: render hint as RGB for eyeballing
hint = rasterize_hint(lay_home(rng), [(0.5, 0.55, 0.3)])
himg = np.stack([hint[0], hint[1], hint[2] + hint[3]], -1)
Image.fromarray((himg * 255).astype(np.uint8)).resize((256, 544)).save(
os.path.join(OUT, "os6_hint_preview.png"))
print("previews saved")