summaryrefslogtreecommitdiffstats
path: root/dundundun.sh
blob: fc9b48d400571aa306111546f439dc765e2fb918 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

source ./shakeoffsets.sh

declare -a shakeOffsets
getShakeOffsets shakeOffsets

SOURCEBASE=$1
SOURCESVG=`printf "%s.svg" $SOURCEBASE`
TARGETSVG=`printf "export/%s.png" $SOURCEBASE`

mkdir -p export_tmp
rm -f export_tmp/*


inkscape -z -e "export_tmp/1_raw.png" `printf "%s1.svg" $SOURCEBASE`
inkscape -z -e "export_tmp/2_raw.png" `printf "%s2.svg" $SOURCEBASE`
inkscape -z -e "export_tmp/3_raw.png" `printf "%s3.svg" $SOURCEBASE`
inkscape -z -e "export_tmp/4_raw.png" `printf "%s4.svg" $SOURCEBASE`

counter=5
NUMPROCS=8
NUMJOBS="\j"
while [ $counter -le 79 ]
do
    while (( ${NUMJOBS@P} >= NUMPROCS )); do
        wait -n
    done
    offset=${shakeOffsets[counter-5]}
    file=`printf "export_tmp/%s_raw.png" $counter`
    source=`printf "%s4.svg" $SOURCEBASE`
    inkscape -z -e $file -a $offset $source &
    ((counter++))
done

wait -n


counter=1
while [ $counter -le 79 ]
do
    while (( ${NUMJOBS@P} >= NUMPROCS )); do
        wait -n
    done
    file=`printf "export_tmp/%s.png" $counter`
    source=`printf "export_tmp/%s_raw.png" $counter`
    pngquant -o $file $source &
    ((counter++))
done

wait -n


declare -a args
args+=(export_tmp/1.png 50:50)
args+=(export_tmp/2.png 12:50)
args+=(export_tmp/3.png 12:50)

counter=4
while [ $counter -le 79 ]
do
    file=`printf "export_tmp/%s.png" $counter`
    args+=($file 1:50)
    ((counter++))
done

apngasm -o $TARGETSVG ${args[@]}
#rm -f export_tmp/*