-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-tinted-icons.sh
executable file
·63 lines (51 loc) · 1.25 KB
/
generate-tinted-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
#!/usr/bin/env bash
set -e
DARK_ICONS=(
ic_refresh_white_24dp.png
ic_search_white_24dp.png
ic_share_white_24dp.png
)
LIGHT_ICONS=(
ic_refresh_black_24dp.png
ic_search_black_24dp.png
ic_share_black_24dp.png
)
DARK_DEFAULT_COLOR=ffffff
LIGHT_DEFAULT_COLOR=000000
BASEDIR=$(dirname $0)
function showHelp {
echo "Usage: $0 (dark|light) tintColor"
echo "Example: $0 light 0000ff"
exit 1
}
if [[ $# -ne 2 ]]; then
showHelp
fi
theme=`echo $1 | tr '[:upper:]' '[:lower:]'`
tintColor=`echo $2 | tr '[:upper:]' '[:lower:]'`
if [[ $theme = light ]]; then
icons=("${LIGHT_ICONS[@]}")
defaultColor=$LIGHT_DEFAULT_COLOR
elif [[ $theme = dark ]]; then
icons=("${DARK_ICONS[@]}")
defaultColor=$DARK_DEFAULT_COLOR
else
showHelp
fi
if [[ ${#tintColor} -ne 6 ]]; then
showHelp
fi
if [[ $tintColor = $defaultColor ]]; then
echo "Requested color $tintColor is same as default for theme. Exiting."
exit
fi
for drawable in `ls -d $BASEDIR/app/src/main/res/drawable*`; do
for file in "${icons[@]}"; do
filePath=$drawable/$file
if [[ -s "$filePath" ]]; then
echo Tinting $filePath
convert $filePath -fill "#$tintColor" -colorize 100% $filePath
optipng $filePath
fi
done
done