56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
from typing import Tuple
|
|
from ilda.frame import Frame
|
|
import sys
|
|
|
|
CANVAS_SIZE: [Tuple[float, float]] = (1000.0,1000.0) # svg canvas size
|
|
TOL: float = 2.0 # svg path tolerance
|
|
|
|
def convert_to_ild(infile: str, outfile: str, simplify: bool = False) -> None:
|
|
frame = Frame()
|
|
try:
|
|
frame.read_svg(infile, simplify=True, tol=TOL)
|
|
except FileNotFoundError:
|
|
print(f"Input file '{infile}' not found.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
frame.write_ild(outfile)
|
|
print(f"Wrote ILDA to {outfile}")
|
|
|
|
def convert_to_svg(infile: str, outfile: str, simplify: bool = False, mintravel: bool = False) -> None:
|
|
frame = Frame()
|
|
try:
|
|
frame.read_svg(infile, simplify=True, tol=TOL)
|
|
except FileNotFoundError:
|
|
print(f"Input file '{infile}' not found.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
frame.write_svg(outfile,canvas_size=CANVAS_SIZE)
|
|
print(f"Wrote (simplified) SVG to {outfile}")
|
|
|
|
|
|
def main() -> None:
|
|
convert_to_ild('frame/hs.svg',
|
|
'frame/hs.ild',
|
|
simplify=True)
|
|
convert_to_ild('frame/text-paths.svg',
|
|
'frame/text-paths.ild',
|
|
simplify=True)
|
|
convert_to_ild('frame/opos.svg',
|
|
'frame/opos.ild',
|
|
simplify=True)
|
|
convert_to_ild('frame/rgb.svg',
|
|
'frame/rgb.ild',
|
|
simplify=True)
|
|
|
|
convert_to_svg('frame/opos.svg',
|
|
'frame/opos-simpl.svg',
|
|
simplify=True)
|
|
convert_to_svg('frame/text-paths.svg',
|
|
'frame/text-paths-simpl.svg',
|
|
simplify=True,
|
|
mintravel=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |