A very-much-so-held-together-by-tape helper for converting SVGs to SGI FTI vector format.
python3 -m pip install -r requirements.txt
usage: svg2fti.py [-h] --svg SVG [--out OUT] [--num_samples NUM_SAMPLES] [--color_map COLOR_MAP]
svg2fti.py: error: the following arguments are required: --svg
python3 svg2fti.py --svg nedit.svg
Input SVG on left.
Output FTI on right as visualized by Aqua Phoenix FTI Editor
- Polygon vs line: if a fill color value cannot be resolved,
bgnline()
is used - Scale: FTI coords are 100x100,
- Curves: SVG paths mapped to lists of vertices, increasing
num_samples
will make smoother
Colors parsed with tinycss2.color3
from:
-
stroke
-
fill
-
style
-
Gradients are ignored
-
Try to follow
url(#id)
: the first (via xpath query) color attribute is chosen
- Valid values are 0 -> 15, -16 -> -255
- 0 -> 15 are a basic color table
- -16 -> -255 are other colors that are interpolated combinations of colors 0 -> 15
color_map.json
contains a mapping of FTI color palette index to RGB values- Only palette colors available, color with smallest delta to input chosen
- svg.path and tinycss2 made it possible to sketch this up so fast!
- AquaPhoenix's FTI Editor & Specs helped make testing this not painful.
Everything else (c) David Stancu 2021 and contributors.