#!/usr/bin/env python3 """IRON ARC art pipeline. python3 tools/art/artgen.py all # brand assets + Flutter tokens python3 tools/art/artgen.py brand # icons, splash, feature graphic python3 tools/art/artgen.py palette # app/lib/src/ui/palette.dart python3 tools/art/artgen.py preview # contact sheet in build/art-preview Everything is SVG-authored and rasterised with librsvg, so the sources stay editable and every size is crisp. Colours come from palette.json - change a token there, re-run, and icons, splash, feature graphic and app theme follow. """ from __future__ import annotations import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import artlib as A import gen_brand as brand DART_OUT = A.ROOT / "app" / "lib" / "src" / "ui" / "palette.dart" DART_HEADER = """// GENERATED FILE - do not edit by hand. // Source: tools/art/palette.json, generator: tools/art/artgen.py // Re-run `python3 tools/art/artgen.py palette` after changing a token. import 'package:flutter/material.dart'; /// Design tokens shared by the app and the generated art. abstract final class Palette { """ def _dart_color(value: str) -> str: h = value.lstrip("#").upper() if len(h) == 6: h = "FF" + h return f"Color(0x{h})" def write_palette() -> Path: data = json.loads((A.ART_DIR / "palette.json").read_text(encoding="utf-8")) lines = [DART_HEADER] for group, values in data.items(): if group.startswith("$") or not isinstance(values, dict): continue lines.append(f" // {group}") for key, value in values.items(): if isinstance(value, str) and value.startswith("#"): name = f"{group}{key[0].upper()}{key[1:]}" lines.append(f" static const {name} = {_dart_color(value)};") lines.append("") lines.append("}") text = "\n".join(lines) + "\n" DART_OUT.parent.mkdir(parents=True, exist_ok=True) DART_OUT.write_text(text, encoding="utf-8") return DART_OUT def main(argv: list[str]) -> int: cmd = argv[1] if len(argv) > 1 else "all" if cmd in ("brand", "all"): for path in brand.write_all(): print(f" {path.relative_to(A.ROOT)} {path.stat().st_size} B") if cmd in ("palette", "all"): print(f" {write_palette().relative_to(A.ROOT)}") if cmd in ("preview", "all"): print("preview:", brand.preview().relative_to(A.ROOT)) if cmd not in ("brand", "palette", "preview", "all"): print(__doc__) return 2 return 0 if __name__ == "__main__": raise SystemExit(main(sys.argv))