-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimate.sh
executable file
·79 lines (68 loc) · 1.67 KB
/
animate.sh
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
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
trap "exit" INT
operation="$1"
param="$2"
steps=50
function generate {
for (( step=0; step<=$steps; step++ ))
do
echo "generating step $step/$steps..."
lein run $steps $step $1
done
}
function animation_dir {
echo "things/animation/$1"
}
function scad_dir {
echo "$(animation_dir $1)/scad"
}
function png_dir {
echo "$(animation_dir $1)/png"
}
function render {
for (( step=0; step<=$steps; step++ ))
do
echo "rendering step $step/$steps..."
openscad -o "$(png_dir $1)/$step.png" --colorscheme "Tomorrow Night" --projection o "$(scad_dir $1)/$step.scad"
done
}
function gif {
all_pngs=""
for (( step=0; step<=$steps; step++ ))
do
all_pngs="$all_pngs $(png_dir $1)/$step.png"
done
out="$(animation_dir $param)/$param.gif"
convert -delay 10 -loop 0 $all_pngs "$out"
convert "$out" -delay 10 -coalesce -duplicate 1,-2-1 -quiet -layers OptimizePlus -loop 0 "$out"
}
all_operations="generate render gif"
operations="$operation"
if [ "$operation" == "all" ]; then
operations="$all_operations"
fi
all_params="z-rot extra-dist x-off x-rot z-off init-z-rot"
params="$param"
if [ "$param" == "all" ]; then
params="$all_params"
fi
for param in $params; do
mkdir -p "$(scad_dir $param)"
mkdir -p "$(png_dir $param)"
done
for param in $params; do
echo "--- $param ---"
for operation in $operations; do
case $operation in
"generate")
generate $param
;;
"render")
render $param
;;
"gif")
gif $param
;;
esac
done
done