Some checks failed
review/design-claude B1-B5,B7 fixed; B8 readiness item glyph/gap geometry deviates from locked st-086
31 lines
1.3 KiB
Python
Executable file
31 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""Rasterize locked prototype rating marks at the Coming-in row's native pixel size."""
|
|
from pathlib import Path
|
|
import hashlib
|
|
import json
|
|
import cairosvg
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
SOURCE = ROOT / "request-marks"
|
|
OUTPUT = ROOT / "src/main/res/drawable-nodpi"
|
|
|
|
|
|
def main() -> None:
|
|
"""Keep the original SVGs and record hashes alongside generated television-size PNGs."""
|
|
OUTPUT.mkdir(parents=True, exist_ok=True)
|
|
tokens = json.loads((ROOT / "tokens.json").read_text())
|
|
supplement = json.loads((ROOT / "shell-tokens.json").read_text())
|
|
height = int(tokens["type"]["label"]["px"])
|
|
wordmark_ratio = supplement["requests"]["ratingsWordmarkRatio"]["$value"]
|
|
manifest = []
|
|
for source in sorted(SOURCE.glob("*.svg")):
|
|
target = OUTPUT / f"coming_in_rating_{source.stem}.png"
|
|
width = round(height * wordmark_ratio) if source.stem in ("imdb", "tmdb") else height
|
|
cairosvg.svg2png(url=str(source), write_to=str(target), output_width=width, output_height=height)
|
|
for path in (source, target):
|
|
manifest.append(f"{hashlib.sha256(path.read_bytes()).hexdigest()} {path.relative_to(ROOT)}")
|
|
(ROOT / "request-marks.sha256").write_text("\n".join(manifest) + "\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|