Add the render script.
This commit is contained in:
parent
089f09864b
commit
692e1eafc4
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
from typing import Any, List, Optional
|
||||
|
||||
|
||||
def main() -> None:
|
||||
resolutions = [64, 128, 256, 512, 1024, 2048]
|
||||
|
||||
for svg in Path("public/").glob("**/*.svg"):
|
||||
if "square" in str(svg):
|
||||
for resolution in resolutions:
|
||||
convert_to_image(
|
||||
source=svg,
|
||||
destination=svg.with_name(f"{svg.stem}-{resolution}.png"),
|
||||
width=resolution,
|
||||
height=resolution,
|
||||
)
|
||||
else:
|
||||
convert_to_image(source=svg, destination=svg.with_suffix(".png"))
|
||||
|
||||
|
||||
def convert_to_image(
|
||||
source: Path,
|
||||
destination: Path,
|
||||
width: Optional[int] = None,
|
||||
height: Optional[int] = None,
|
||||
) -> None:
|
||||
inkscape_args: List[str] = ["inkscape", str(source), "-o", str(destination)]
|
||||
|
||||
if width is not None and height is not None:
|
||||
inkscape_args.extend(["-w", str(width), "-h", str(height)])
|
||||
|
||||
run(args=inkscape_args)
|
||||
mat2_image(destination)
|
||||
|
||||
|
||||
def mat2_image(image: Path) -> None:
|
||||
run(args=["mat2", "--inplace", image])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue