-
-
Notifications
You must be signed in to change notification settings - Fork 476
/
mk_mac_icons.sh
144 lines (118 loc) · 4.19 KB
/
mk_mac_icons.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#
# make macos icons using Inkscape
mkdir macos_tmp
# convert .svg files into .png files
SIZES="16x16
32x32
128x128
256x256
512x512
1024x1024"
ICONS="bitmap2component
eeschema
gerbview
kicad
pagelayout_editor
pcbcalculator
pcbnew"
DOCS="project
schematic
pcb
footprint
symbol
worksheet"
for doc in $DOCS
do
output=""
for size in $SIZES
do
sz=${size%x*}
echo -e '\E[0;32m'"\nMaking the documents icons with size $size."
# MacOS wants icons with 10% clearance on each side
let "sub_sz = $sz * 8 / 10"
sigma=3
if [ $sz -eq 16 ]
then
sigma=2
elif [ $sz -ge 512 ]
then
sigma=5
fi
# Offset the drop shadow by one smaller than the kernel
let "off = $sigma - 1"
# Use specialized icons for smaller sizes to keep pixel alignment
if [ $sz -le 32 ]
then
inkscape linux/icons/hicolor/scalable/mimetypes/application-x-kicad-${doc}-${sz}.svg -o macos_tmp/${doc}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
else
inkscape linux/icons/hicolor/scalable/mimetypes/application-x-kicad-${doc}.svg -o macos_tmp/${doc}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
fi
convert macos_tmp/${doc}_small_${sz}px.png \( +clone -background black -shadow 80x${sigma}+${off}+${off} \) +swap -background transparent -layers merge +repage -size $size xc:transparent +swap -gravity center -composite macos_tmp/${doc}_${sz}px.png
output+="macos_tmp/${doc}_${sz}px.png "
done
png2icns macos_tmp/${doc}.icns ${output}
done
for pgm in $ICONS
do
output=""
for size in $SIZES
do
sz=${size%x*}
echo -e '\E[0;32m'"\nMaking the applications icons with size $size."
# MacOS wants icons with 10% clearance on each side
let "sub_sz = $sz * 8 / 10"
sigma=3
if [ $sz -eq 16 ]
then
sigma=2
elif [ $sz -ge 512 ]
then
sigma=5
fi
# Offset the drop shadow by one smaller than the kernel
let "off = $sigma - 1"
# Use specialized icons for smaller sizes to keep pixel alignment
if [ $sz -le 32 ]
then
inkscape bitmaps_png/sources/light/icon_${pgm}_${sz}.svg -o macos_tmp/${pgm}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
else
inkscape bitmaps_png/sources/light/icon_${pgm}.svg -o macos_tmp/${pgm}_small_${sz}px.png -w ${sub_sz} -h ${sub_sz} --export-area-snap
fi
convert macos_tmp/${pgm}_small_${sz}px.png \( +clone -background black -shadow 80x${sigma}+${off}+${off} \) +swap -background transparent -layers merge +repage -size $size xc:transparent +swap -gravity center -composite macos_tmp/${pgm}_${sz}px.png
output+="macos_tmp/${pgm}_${sz}px.png "
done
case ${pgm} in
pcbcalculator)
# mismatch in the pcbcalculator icon names
png2icns ../pcb_calculator/pcb_calculator.icns ${output}
;;
bitmap2component)
# bitmap2component does not have associated documents
png2icns ../${pgm}/${pgm}.icns ${output}
;;
eeschema)
png2icns ../${pgm}/${pgm}.icns ${output}
cp macos_tmp/schematic.icns ../${pgm}/${pgm}_doc.icns
cp macos_tmp/symbol.icns ../${pgm}/libedit_doc.icns
;;
pcbnew)
png2icns ../${pgm}/${pgm}.icns ${output}
cp macos_tmp/pcb.icns ../${pgm}/${pgm}_doc.icns
cp macos_tmp/footprint.icns ../${pgm}/fpedit_doc.icns
;;
kicad)
png2icns ../${pgm}/${pgm}.icns ${output}
cp macos_tmp/project.icns ../${pgm}/${pgm}_doc.icns
;;
pagelayout_editor)
png2icns ../${pgm}/${pgm}.icns ${output}
cp macos_tmp/worksheet.icns ../${pgm}/${pgm}_doc.icns
;;
*)
png2icns ../${pgm}/${pgm}.icns ${output}
cp ../${pgm}/${pgm}.icns ../${pgm}/${pgm}_doc.icns
;;
esac
done
# rm -rf macos_tmp