forked from andybalaam/rabbit-escape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
record-gifs
executable file
·63 lines (50 loc) · 1.35 KB
/
record-gifs
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
#!/bin/bash
# Records some animations of rabbits to make into animated gifs.
# Prerequisites:
# sudo apt-get install wmctrl byzanz
function wait_for_window()
{
echo -n "Waiting for a window called '$1' .."
while ! wmctrl -l | \
cut -d' ' --complement -f 1,2,3,4 | \
grep '^'"$1"'$' > /dev/null; do
{
echo -n .
sleep 1
}; done
echo " found"
}
function move_window()
{
wait_for_window "$1"
echo "Moving window '$1' to position '$2'."
wmctrl -F -r "$1" -e "0,$2"
}
function close_window()
{
echo "Closing window '$1'."
wmctrl -F -c "$1"
}
function record_level()
{
LEV="$1"
X="$2"
Y="$3"
WIDTH="$4"
HEIGHT="$5"
DELAY="$6"
DURATION="$7"
LEVELS="rabbit-escape-engine/src/rabbitescape/levels/gifs"
mkdir -p bin/gifs
./runrabbit swing "--level=${LEVELS}/${LEV}.rel" --solution=1 > /dev/null &
byzanz-record \
"--x=$X" "--y=$Y" "--width=$WIDTH" "--height=$HEIGHT" \
"--delay=$DELAY" "--duration=$DURATION" \
bin/gifs/"${LEV}.gif"
close_window "Rabbit Escape"
}
./runrabbit swing --level=01_easy/level_01.rel --solution=1 > /dev/null &
move_window "Rabbit Escape" 50,50,1024,768
sleep 1 # Rabbit Escape doesn't like to be closed immediately after opening
close_window "Rabbit Escape"
record_level bridge_to_fire 292 370 512 380 4 10