]> de.git.xonotic.org Git - xonotic/mediasource.git/blobdiff - gfx/crosshairs/luma/render.sh
Render Luma crosshairs with Inkscape to avoid rsvg inconsistencies
[xonotic/mediasource.git] / gfx / crosshairs / luma / render.sh
diff --git a/gfx/crosshairs/luma/render.sh b/gfx/crosshairs/luma/render.sh
new file mode 100755 (executable)
index 0000000..4d93ba2
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -e
+
+# Task:
+#   Render SVG files from ./path/file.svg to OUTDIR/path/file.tga
+#   Overwrites existing tga files.
+#
+# Usage:
+#   ./render.sh OUTDIR SVG...
+#
+# Examples:
+#   One file:  ./render.sh ~/.xonotic/data gfx/crosshair64.svg
+#   All files: ./render.sh ~/.xonotic/data $(find . -name "*.svg")
+#
+# Dependencies:
+#   Inkscape (1.0.1)
+#   ImageMagick (7.0.7)
+
+outDir="$1"; shift
+
+for svg in "$@"; do
+       # Extract name components
+       svgDir=$(dirname -- "$svg")
+       svgName=$(basename -- "$svg" .svg)
+
+       # Compose target file names
+       dir="$outDir/$svgDir"
+       tga="$dir/$svgName.tga"
+       tmp="$dir/$svgName.tmp.png"
+
+       # Ensure target directory exists
+       mkdir --parent "$dir"
+
+       # Render image
+       inkscape --export-filename "$tmp" "$svg"
+       convert -auto-orient "$tmp" -compress RLE "$tga"
+       rm "$tmp"
+done