-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_icons
executable file
·58 lines (43 loc) · 1.18 KB
/
make_icons
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
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
my %sizes = (
mdpi => [ 24, 32, 48 ],
hdpi => [ 36, 48, 72 ],
xhdpi => [ 48, 64, 96 ],
xxhdpi => [ 72, 96, 144 ],
xxxhdpi => [ 96, 128, 192 ],
);
my @icons = qw(search lock);
sub run {
say join ' ', @_;
system @_;
}
sub svg2png {
my ($source, $dest, $size, $id) = @_;
my @params = (
$source, '--export-png', $dest, '--export-height', $size, '--export-width',
$size
);
push @params, '--export-id-only', '--export-id', $id if $id;
run('inkscape', @params);
}
sub pad {
my ($file, $original, $padded) = @_;
my $border = ($padded - $original) / 2;
run('convert', $file, '-bordercolor', 'none', '-border', $border, $file);
}
for my $icon (@icons) {
for my $size (keys %sizes) {
my $file = "res/drawable-$size/ic_menu_$icon.png";
run('mkdir', '-p', "res/drawable-$size");
svg2png('art/icons.svg', $file, $sizes{$size}[0], $icon);
pad($file, $sizes{$size}[0], $sizes{$size}[1]);
}
}
for my $size (keys %sizes) {
my $file = "res/drawable-$size/ic_launcher.png";
svg2png('art/launcher.svg', $file, $sizes{$size}[2]);
}
svg2png('art/launcher.svg', 'art/icon.png', 512);