summaryrefslogtreecommitdiff
path: root/scripts/cubeviz
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-05-06 08:30:49 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-05-06 08:30:49 +0200
commit60052659b98832c78c902e4f27ecee2663d8e913 (patch)
tree9efc1388569c43456557aa1975b4bec99bf06c94 /scripts/cubeviz
parent10e16c2fb2266bb2b46ec7ea64d721de0c29a0d9 (diff)
downloadconfig-60052659b98832c78c902e4f27ecee2663d8e913.tar.gz
config-60052659b98832c78c902e4f27ecee2663d8e913.zip
Added scripts
Diffstat (limited to 'scripts/cubeviz')
-rwxr-xr-xscripts/cubeviz62
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/cubeviz b/scripts/cubeviz
new file mode 100755
index 0000000..da453c2
--- /dev/null
+++ b/scripts/cubeviz
@@ -0,0 +1,62 @@
1#!/bin/sh
2
3# Get images for a Rubik's cube state from http://cube.rider.biz/visualcube.php
4# Can be used with a local installation of visualcube.
5
6# Usage: cubeviz [type] [alg]
7# See usage() for details
8# Requires: curl, ImageMagick
9
10visualcube="http://cube.rider.biz/visualcube.php"
11
12usage() {
13 echo "Usage: cubeviz [type] [alg]"
14 echo "Types: trigger"
15 echo "Alg: use the standard notation"
16}
17
18trigger() {
19 alg="$(echo "$1" | tr "'" "3" | tr -d " ")"
20 w="wwwwwwwww"
21 y="yyyyyyyyy"
22 l="lllllllll"
23 d="ddddddddd"
24 t="ttttttttt"
25 ud="$visualcube?fmt=svg&fc=$y$l$l$y$l$l&size=200&view=plan"
26 top="$ud&alg=$alg"
27 bottom="$ud&alg=${alg}x2"
28 s="$visualcube?fmt=svg&fc=$y$t$t$y$t$t&size=200&r=y30x-30"
29 side="$s&co=30&alg=$alg"
30
31 d="pics_tmp"
32 f="trigger_$alg.png"
33
34 # We need some temporary files because visualcube is broken
35 # on Conrad's website and cannot output formats other than svg.
36 mkdir "$d"
37 curl "$top" > $d/top.svg
38 curl "$bottom" > $d/bottom.svg
39 curl "$side" > $d/side.svg
40
41 c="convert -density 400"
42 $c $d/top.svg $d/top.png
43 $c $d/bottom.svg $d/bottom.png
44 $c $d/side.svg $d/side.png
45
46 montage -tile 2x2 -mode concatenate \
47 $d/top.png $d/side.png $d/bottom.png $f
48
49 rm -r "$d"
50}
51
52[ -z "$2" ] && usage && exit 1
53
54case "$1" in
55 trigger)
56 trigger "$2"
57 ;;
58 *)
59 usage
60 exit 1
61 ;;
62esac

Generated with cgit - Back to sebastiano.tronto.net