-
Notifications
You must be signed in to change notification settings - Fork 19
/
create-pointer.sh
executable file
·73 lines (65 loc) · 2.31 KB
/
create-pointer.sh
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
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#
outputfolder="docs/img/overlays"
if [[ ! -d "$outputfolder" ]]; then
mkdir -p "$outputfolder"
fi
# Create base arrow image
convert -size 72x284 \
xc:transparent \
-strokewidth 0 \
-stroke red \
-fill red \
-draw "ellipse 36,271 9,9 0,360" \
-draw "polygon 36,4 4,76 27,65 27,271 45,271 45,65 68,76" \
${outputfolder}/pointer.png
width=10
wfact=$((1000 * width))
depth=40
icontr=$(convert xc: -format "%[fx:(0.5*$depth-100)]" info:)
for entry in 0 45 90 135 180 225 270 315; do
# Rotate the pointer
convert -rotate ${entry} -background 'rgba(0,0,0,0)' ${outputfolder}/pointer.png ${outputfolder}/pointer-${entry}.png
# Add the bevel
convert ${outputfolder}/pointer-${entry}.png -bordercolor none -border 10x10 -write mpr:img \
-alpha extract -write mpr:alpha \
+level 0,1000 -white-threshold 999 \
-morphology Distance:-1 Euclidean:$width,1000 -level 0,"$wfact" \
-shade 120x45 -auto-level -brightness-contrast 0,"$icontr" \
\( +clone -fill "gray(50%)" -colorize 100% \) +swap \( mpr:alpha -threshold 0 \) \
-compose over -composite \
\( mpr:img -alpha off \) +swap -compose hardlight -composite \
mpr:alpha -alpha off -compose copy_opacity -composite \
-shave 10x10 \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add a white border
convert ${outputfolder}/pointer-${entry}.png \
-bordercolor none -border 20 \
\( -clone 0 -fill white -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:2 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:2 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add a black border
convert ${outputfolder}/pointer-${entry}.png \
-bordercolor none -border 20 \
\( -clone 0 -fill black -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:1 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:1 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add the drop shadow
convert ${outputfolder}/pointer-${entry}.png \
\( +clone -background black -shadow 50x10+10+10 \) \
+swap \
-background none \
-layers merge \
+repage \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
done