Introduction
Introduction Statistics Contact Development Disclaimer Help
moves.sh - chess-puzzles - chess puzzle book generator
git clone git://git.codemadness.org/chess-puzzles
Log
Files
Refs
README
LICENSE
---
moves.sh (1409B)
---
1 #!/bin/sh
2 # make a list of moves from start to end for each move.
3
4 # output moves to tty with some delay.
5 # Show PGN and human speech-like text for the moves.
6 output_tty() {
7 while read -r moves; do
8 clear
9 ./fen -o tty "$fen" "$moves"
10 echo ""
11 ./fen -o pgn "$fen" "$moves"
12 echo ""
13 ./fen -o speak -l "$fen" "$moves"
14 sleep 2
15 done
16 }
17
18 # create an animated gif.
19 # Dependencies: ffmpeg, ImageMagick, etc.
20 output_gif() {
21 tmppal="$(mktemp '/tmp/palette_XXXXXXXX.png')"
22 tmpdir="$(mktemp -d '/tmp/fen_gif_XXXXXXXX')"
23
24 n=1
25 while read -r moves; do
26 f="$tmpdir/$n.svg"
27 ./fen -o svg "$fen" "$moves" > "$f"
28 test -s "$f" || break
29
30 dest="$tmpdir/$n.png"
31 convert "$f" "$dest"
32
33 n=$((n + 1))
34 done
35
36 # generate palette for gif.
37 rm -f "$tmppal"
38 ffmpeg -loglevel error -stats -i "$tmpdir/%d.png"\
39 -vf palettegen "$tmppal"
40
41 # create video / animation.
42 # wait longer for last frame.
43 ffmpeg -loglevel error -stats -framerate 1\
44 -i "$tmpdir/%d.png" \
45 -i "$tmppal" \
46 -lavfi 'tpad=stop_mode=clone:stop_duration=4[v];[v]palet…
47 -map '[out]' \
48 -f gif \
49 -
50
51 rm -rf "$tmpdir"
52 rm -f "$tmppal"
53 }
54
55 if [ "$1" = "" ] || [ "$2" = "" ]; then
56 echo "$0 <fen> <moves>" >&2
57 exit 1
58 fi
59
60 fen="$1"
61 m="$2"
62 while [ "$m" != "" ]; do
63 prevmoves="$m"
64 echo "$m"
65
66 m="${m% }"
67 m="${m%[^ ]*}"
68 m="${m% }"
69
70 test "$prevmoves" = "$m" && break # same, break also
71 done | \
72 sort | \
73 output_gif
74
75 #output_tty
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.