aboutsummaryrefslogtreecommitdiff
path: root/src/speedcubing/triggers/gen.sh
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-01-27 17:18:11 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-01-27 17:18:11 +0100
commit1d0ab35c076208fa232cc155cbdd7d49430092a6 (patch)
treec2bd2bd24137030814eacc23f500ba99268044a5 /src/speedcubing/triggers/gen.sh
parent7dac2c3bc3ea70ed52b25a08566b760af41e6f1a (diff)
downloadsebastiano.tronto.net-1d0ab35c076208fa232cc155cbdd7d49430092a6.tar.gz
sebastiano.tronto.net-1d0ab35c076208fa232cc155cbdd7d49430092a6.zip
started page on DR triggers
Diffstat (limited to 'src/speedcubing/triggers/gen.sh')
-rwxr-xr-xsrc/speedcubing/triggers/gen.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/speedcubing/triggers/gen.sh b/src/speedcubing/triggers/gen.sh
new file mode 100755
index 0000000..83b9f51
--- /dev/null
+++ b/src/speedcubing/triggers/gen.sh
@@ -0,0 +1,48 @@
1#!/bin/sh
2
3invert() {
4 # To invert an alg, replace R2 with RR, B' with B3 and then BBB
5 # and similar. Then reverse the string and triple every letter.
6 # It's a ugly hack, but it works.
7 alg="$(echo "$1" | tr -d ' ' | tr \' 3)"
8 echo "$alg" | sed -E 's/(.)(3)/\1\1\1/g' | \
9 sed -E 's/(.)(2)/\1\1/g' | sed 's/./&&&/g' | rev
10}
11
12gen() {
13 [ -e "trigger_$1.png" ] || cubeviz trigger "$1" > /dev/null 2>&1
14}
15
16printitem() {
17 alg="$1"
18 if [ -n "$alg" ]; then
19 inv="$(invert "$alg")"
20 echo "Working on alg $alg with inverse $inv" 1>&2
21 gen "$inv"
22 printf '<td style="font-size:16pt; text-align:center" '
23 printf 'width="20%%">%s</td>\n' "$alg"
24 printf '<td><a href="trigger_%s.png">\n' "$inv"
25 printf '<img src="trigger_%s.png" ' "$inv"
26 printf 'style="height:100px"></a></td>\n'
27 else
28 printf '<td width="20%%"><td width="30%%">\n'
29 fi
30}
31
32maketable() {
33 alg1="$(echo "$1" | sed 's/;.*$//' | tr -d '!')"
34 alg2="$(echo "$1" | sed 's/.*;//')"
35 printf '<table><tr>\n'
36 printitem "$alg1"
37 printitem "$alg2"
38 printf '</tr></table>\n'
39}
40
41while read -r line; do
42 algs="$(echo "$line" | grep '^!')"
43 if [ -z "$algs" ]; then
44 echo "$line"
45 else
46 maketable "$line"
47 fi
48done

Generated with cgit - Back to sebastiano.tronto.net