"""Writes surfaces_manta.py: surfaces_head.py (the Manta's sets and atlases) + the helper functions of the Remora's surfaces_remora.py (UV layers, screens, bake, node dressing; lines from '# --- UV layers' to the end of dress_glass) with the names changed + surfaces_tail.py (the run). Plain python: python build/make_surfaces.py""" import os HERE = os.path.dirname(os.path.abspath(__file__)) src = open(os.path.join(HERE, "..", "..", "tender-remora", "build", "surfaces_remora.py"), encoding="utf-8").read() a = src.index("# ------------------------------------------------------------------ UV layers") b = src.index("# ------------------------------------------------------------------ run") body = src[a:b] for old, new in [ ('"REMORA | Screen"', '"MANTA | Screen"'), ("T_Remora_", "T_Manta_"), ("img[:] = (0.004, 0.018, 0.030)", "img[:] = (0.022, 0.011, 0.004)"), ("cyan = np.array((0.10, 0.85, 1.0), np.float32)", "cyan = np.array(SCREEN_INK, np.float32)"), ("np.array((1.0, 0.55, 0.10))", "np.array(SCREEN_ALERT)"), ("if p.normal.z > 0.8 and p.normal.y > 0.2: # the display, facing up and back toward the seat", "if p.normal.y > 0.8: # the display, facing back toward the seat"), ("ymin, ymax = min(c.y for c in xs), max(c.y for c in xs)", "ymin, ymax = min(c.z for c in xs), max(c.z for c in xs)"), ("vv = 0.04 + 0.92 * (c.y - ymin) / (ymax - ymin)", "vv = 0.04 + 0.92 * (c.z - ymin) / (ymax - ymin)")]: assert old in body, old body = body.replace(old, new) assert "REMORA" not in body and "Remora" not in body.replace("Remora's", ""), [l for l in body.splitlines() if "emora" in l] out = open(os.path.join(HERE, "surfaces_head.py"), encoding="utf-8").read() + body + open(os.path.join(HERE, "surfaces_tail.py"), encoding="utf-8").read() open(os.path.join(HERE, "surfaces_manta.py"), "w", encoding="utf-8").write(out) print("written", len(out.splitlines()), "lines")