Debian Codegraph @

cursors/src/split_monilithic_svg

raw
1 #!/bin/bash
2 # This script splits the monolithic cursors.svg into individual SVGs for each cursor.
3 # Run in Breeze/. Results are in Breeze/src/svg.
4
5 set -euo pipefail
6
7 RAWSVG="src/cursors.svg"
8 BINDIR="$( dirname "${BASH_SOURCE[0]}" )"
9
10 echo -ne "Checking Requirements...\\r"
11 if [[ ! -f "${RAWSVG}" ]]; then
12 echo -e "\\nFAIL: '${RAWSVG}' missing"
13 exit 1
14 fi
15
16 if ! command -v inkscape > /dev/null ; then
17 echo -e "\\nFAIL: inkscape must be installed"
18 exit 1
19 fi
20 echo "Checking Requirements... DONE"
21
22 echo "Splitting..."
23 DIR="src/svg"
24 mkdir -p $DIR
25
26 for CUR in src/config/*.cursor; do
27 BASENAME=${CUR##*/}
28 BASENAME=${BASENAME%.*}
29
30 echo -ne "$BASENAME...\\r"
31
32 if [[ "${DIR}/${BASENAME}.svg" -ot ${RAWSVG} ]]; then
33 # Set viewbox around the cursor
34 inkscape $RAWSVG -i $BASENAME -o /tmp/"$BASENAME".svg >/dev/null
35 # Remove everything except the cursor
36 $BINDIR/clean_svg /tmp/"$BASENAME".svg /tmp/"$BASENAME"-cleaned.svg "$BASENAME"
37 # Remove groups in the middle, and remove Inkscape-specific attributes
38 inkscape /tmp/"$BASENAME"-cleaned.svg -o $DIR/"$BASENAME".svg --actions 'select-all:groups;selection-ungroup;select-all:groups;selection-ungroup;select-all:groups;selection-ungroup' -l > /dev/null
39
40 rm /tmp/"$BASENAME".svg /tmp/"$BASENAME"-cleaned.svg
41 fi
42
43 echo "$BASENAME... DONE"
44 done
45
46
47 for CUR in progress wait; do
48 for i in {01..23}; do
49 BASENAME="${CUR}-${i}"
50
51 echo -ne "$BASENAME...\\r"
52
53 if [[ "${DIR}/${BASENAME}.svg" -ot ${RAWSVG} ]]; then
54
55 # Set viewbox around the cursor
56 inkscape $RAWSVG -i $BASENAME -o /tmp/"$BASENAME".svg >/dev/null
57 # Remove everything except the cursor
58 $BINDIR/clean_svg /tmp/"$BASENAME".svg /tmp/"$BASENAME"-cleaned.svg "$BASENAME"
59 # Remove groups in the middle, and remove Inkscape-specific attributes
60 inkscape /tmp/"$BASENAME"-cleaned.svg -o $DIR/"$BASENAME".svg --actions 'select-all:groups;selection-ungroup;select-all:groups;selection-ungroup' -l > /dev/null
61
62 rm /tmp/"$BASENAME".svg /tmp/"$BASENAME"-cleaned.svg
63 fi
64
65 echo "$BASENAME... DONE"
66 done
67 done
68
69 echo "COMPLETE!"