]> de.git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/luma_add/render.sh
Revise the Luma documentation files
[xonotic/mediasource.git] / gfx / luma_add / render.sh
1 #!/bin/sh -e
2 #
3 # Renders SVG files from ./path/file.svg to OUTDIR/path/file.tga
4 # Overwrites existing tga files
5 #
6 # Usage:
7 #   ./render.sh OUTDIR SVG...
8 #
9 # Examples:
10 #   One file:  ./render.sh ~/.xonotic/data gfx/hud/luma/armor.svg
11 #   All files: ./render.sh ~/.xonotic/data $(find . -name "*.svg")
12 #
13 # Dependencies:
14 #   Inkscape    (0.92.3)
15 #   ImageMagick (7.0.7)
16
17
18 outDir="$1"; shift
19
20
21 for svg in "$@"; do
22         # Extract name components
23         svgDir=$(dirname -- "$svg")
24         svgName=$(basename -- "$svg" .svg)
25
26         # Compose target file names
27         dir="$outDir/$svgDir"
28         tga="$dir/$svgName.tga"
29         tmp="$dir/$svgName.tmp.png"
30
31         # Ensure target directory exists
32         mkdir -p "$dir"
33
34         # Because Inkscape makes it difficult to write to
35         # stdout for piping, a temporary file is used instead
36         inkscape -f "$svg" -e "$tmp"
37         convert "$tmp" "$tga"
38         rm -f "$tmp"
39 done