Merge branch 'refs/heads/t/configtest'
[dss.git] / mklogo
1 #!/bin/bash
2
3 # Script for Image Magick that writes the dss logo in png format
4 # to stdout.
5
6 set -u
7
8 width=320
9 height=110
10 border=5
11 radius1=4
12 radius2=5
13 circle_y=90
14 arrow_y=70
15 text_x=128
16 text_y=55
17 pointsize=36
18
19 declare -a circle arrow rectangle text
20
21 make_circles()
22 {
23         local inner='stroke black fill red circle'
24         local outer='stroke black fill black circle'
25         local num=1
26         local idx=0
27         local y=$circle_y
28         local step x0 i j idx num
29
30         for ((i = 0; i < 4; i++)); do
31                 step=$(((width / 4 + num) / (num + 1)))
32                 x0=$((border + width / 4 * i))
33                 for ((j = 1; j <= $num; j++)); do
34                         x=$((x0 + j * $step))
35                         circle[$idx]='-draw'; let idx++
36                         circle[$idx]="$outer $x,$y,$((x + radius2)),$y"; let idx++
37                         circle[$idx]='-draw'; let idx++
38                         circle[$idx]="$inner $x,$y,$((x + radius1)),$y"; let idx++
39                 done
40                 num=$((num * 2))
41         done
42         #echo "${circle[@]}"; exit 0
43 }
44
45 make_arrow()
46 {
47         local arrow_head='l -15,-5  +5,+5  -5,+5  +15,-5 z'
48         local idx=0
49         local x0 x1 y
50
51         arrow[$idx]='-draw'; let idx++
52         x0=$((3 * border)); x1=$((width - 2 * border))
53         y=$arrow_y
54         arrow[$idx]="stroke white line $x0,$y $x1,$y"; let idx++
55         arrow[$idx]='-draw'; let idx++
56         x0=$((width - 2 * border))
57         arrow[$idx]="stroke white fill white path 'M $x0,$y $arrow_head'"
58         #echo "${arrow[@]}"; exit 0
59 }
60
61 make_rectangles()
62 {
63         local idx=0
64         local x x0 x1 y y0 y1 i red_green color
65
66         rectangle[$idx]='-draw'; let idx++
67         x=$((width + 2 * border))
68         y=$((height + 2 * border))
69         rectangle[$idx]="stroke yellow fill yellow rectangle 0,0 $x,$y"; let idx++
70         for ((i = 0; i < 4; i++)); do
71                 rectangle[$idx]='-draw'; let idx++
72                 red_green="$(printf '%02x' $(((3 - i) * 60)))"
73                 color="#${red_green}${red_green}ff"
74                 x0=$((border + i * width / 4)); x1=$((x0 + width / 4 - 1))
75                 y0=$border; y1=$((y0 + height))
76                 rectangle[$idx]="stroke $color fill $color rectangle $x0,$y0 $x1,$y1"
77                 let idx++
78         done
79         #echo "${rectangle[@]}"; exit 0
80 }
81
82 make_text()
83 {
84         text=(-pointsize $pointsize -draw \
85                 "fill white text $text_x,$text_y DSS")
86         #echo "${text[@]}"; exit 0
87 }
88
89 make_rectangles
90 make_arrow
91 make_circles
92 make_text
93
94 convert -size $((width + 2 * border))x$((height + 2 * border)) \
95         -background none xc: \
96         "${rectangle[@]}" \
97         "${arrow[@]}" \
98         "${circle[@]}" \
99         "${text[@]}" \
100         png:-