@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CLI: сгенерировать кадры Plymouth (800×600) из logo2.png."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.services.plymouth_frame_renderer import ( # noqa: E402
|
||||
DURATION_MS_DEFAULT,
|
||||
PLYMOUTH_FPS,
|
||||
PLYMOUTH_HEIGHT,
|
||||
PLYMOUTH_WIDTH,
|
||||
render_all_frames,
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Render WESP Plymouth animation frames")
|
||||
parser.add_argument(
|
||||
"--logo",
|
||||
type=Path,
|
||||
default=ROOT / "static" / "logo2.png",
|
||||
help="Path to logo2.png",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--out",
|
||||
type=Path,
|
||||
default=ROOT / "data" / "plymouth-build",
|
||||
help="Output directory (animation/ inside)",
|
||||
)
|
||||
parser.add_argument("--width", type=int, default=PLYMOUTH_WIDTH)
|
||||
parser.add_argument("--height", type=int, default=PLYMOUTH_HEIGHT)
|
||||
parser.add_argument("--duration-ms", type=int, default=DURATION_MS_DEFAULT)
|
||||
parser.add_argument("--fps", type=int, default=PLYMOUTH_FPS)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.logo.is_file():
|
||||
print(f"Logo not found: {args.logo}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
def progress(done: int, total: int) -> None:
|
||||
pct = int(100 * done / total) if total else 100
|
||||
print(f"\rFrames {done}/{total} ({pct}%)", end="", flush=True)
|
||||
|
||||
summary = render_all_frames(
|
||||
args.logo,
|
||||
args.out,
|
||||
width=args.width,
|
||||
height=args.height,
|
||||
duration_ms=args.duration_ms,
|
||||
fps=args.fps,
|
||||
progress_callback=progress,
|
||||
)
|
||||
print()
|
||||
print(summary)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user