summaryrefslogtreecommitdiff
path: root/icons/create-icons-from-tango.pl
diff options
context:
space:
mode:
Diffstat (limited to 'icons/create-icons-from-tango.pl')
-rwxr-xr-xicons/create-icons-from-tango.pl141
1 files changed, 93 insertions, 48 deletions
diff --git a/icons/create-icons-from-tango.pl b/icons/create-icons-from-tango.pl
index bfdbe804ac..8cd0ece2d3 100755
--- a/icons/create-icons-from-tango.pl
+++ b/icons/create-icons-from-tango.pl
@@ -22,51 +22,93 @@
22# To be run from the icons/ folder in a Rockbox checkout. 22# To be run from the icons/ folder in a Rockbox checkout.
23 23
24use File::Temp; 24use File::Temp;
25use Getopt::Long;
25 26
26# list of icons for strip 27# list of icons for strip
28# Use relative paths to point to icons in the tree, relative to the icons/ folder
29# (must start with . or ..)
30# Other are treated relatively to the tango sources tree
27my @iconlist = ( 31my @iconlist = (
28 "mimetypes/audio-x-generic", # Icon_Audio 32 "./tango-svg/audio-x-generic", # Icon_Audio
29 "places/folder", # Icon_Folder 33 "./tango-svg/folder", # Icon_Folder
30 "actions/format-indent-more", # Icon_Playlist 34 "./tango-svg/format-indent-more", # Icon_Playlist
31 "actions/media-playback-start", # Icon_Cursor ### 35 "./new_icons-svg/media-playback-start-green", # Icon_Cursor ###
32 "apps/preferences-desktop-wallpaper", # Icon_Wps 36 "./tango-svg/preferences-desktop-wallpaper", # Icon_Wps
33 "devices/computer", # Icon_Firmware ### 37 "./tango-svg/media-flash", # Icon_Firmware ###
34 "apps/preferences-desktop-font", # Icon_Font 38 "./tango-svg/preferences-desktop-font", # Icon_Font
35 "apps/preferences-desktop-locale", # Icon_Language 39 "./tango-svg/preferences-desktop-locale", # Icon_Language
36 "categories/preferences-system", # Icon_Config 40 "./tango-svg/preferences-system", # Icon_Config
37 "status/software-update-available", # Icon_Plugin 41 "./tango-svg/software-update-available", # Icon_Plugin
38 "actions/bookmark-new", # Icon_Bookmark 42 "./tango-svg/bookmark-new", # Icon_Bookmark
39 "places/start-here", # Icon_Preset 43 "./tango-svg/start-here", # Icon_Preset
40 "actions/go-jump", # Icon_Queued 44 "./tango-svg/go-jump", # Icon_Queued
41 "actions/go-next", # Icon_Moving 45 "./tango-svg/go-next", # Icon_Moving
42 "devices/input-keyboard", # Icon_Keyboard 46 "./tango-svg/input-keyboard", # Icon_Keyboard
43 "actions/mail-send-receive", # Icon_Reverse_Cursor 47 "./tango-svg/go-previous", # Icon_Reverse_Cursor
44 "apps/help-browser", # Icon_Questionmark 48 "./tango-svg/help-browser", # Icon_Questionmark
45 "actions/document-properties", # Icon_Menu_setting 49 "./tango-svg/document-properties", # Icon_Menu_setting
46 "categories/applications-other", # Icon_Menu_functioncall 50 "./tango-svg/applications-other", # Icon_Menu_functioncall
47 "actions/list-add", # Icon_Submenu 51 "./tango-svg/list-add", # Icon_Submenu
48 "categories/preferences-system", # Icon_Submenu_Entered 52 "./tango-svg/preferences-system", # Icon_Submenu_Entered
49 "actions/media-record", # Icon_Recording 53 "./tango-svg/media-record", # Icon_Recording
50 "devices/audio-input-microphone", # Icon_Voice ### 54 "./new_icons-svg/face-shout", # Icon_Voice ###
51 "categories/preferences-desktop", # Icon_General_settings_menu 55 "./tango-svg/preferences-desktop", # Icon_General_settings_menu
52 "categories/applications-other", # Icon_System_menu 56 "./tango-svg/emblem-system", # Icon_System_menu
53 "actions/media-playback-start", # Icon_Playback_menu 57 "./tango-svg/media-playback-start", # Icon_Playback_menu
54 "devices/video-display", # Icon_Display_menu 58 "./tango-svg/video-display", # Icon_Display_menu
55 "devices/video-display", # Icon_Remote_Display_menu 59 "./tango-svg/network-receive", # Icon_Remote_Display_menu
56 "devices/network-wireless", # Icon_Radio_screen ### 60 "./tango-svg/network-wireless", # Icon_Radio_screen ###
57 "mimetypes/package-x-generic", # Icon_file_view_menu 61 "./tango-svg/system-file-manager", # Icon_file_view_menu
58 "apps/utilities-system-monitor", # Icon_EQ 62 "./tango-svg/utilities-system-monitor", # Icon_EQ
59 "../docs/logo/rockbox-clef.svg" # Icon_Rockbox 63 "../docs/logo/rockbox-clef" # Icon_Rockbox
60); 64);
65my @iconlist_viewers = (
66 "./tango-svg/applications-graphics", # bmp
67 "./tango-svg/applications-multimedia", # mpeg
68 "./tango-svg/applications-other", # ch8, tap, sna, tzx, z80
69 "./tango-svg/audio-x-generic", # mp3, mid, rmi, wav
70 "./tango-svg/format-justify-left", # txt, nfo
71 "./tango-svg/text-x-generic-template", # ss
72 "./mint-x-svg/applications-games", # gb, gbc
73 "./tango-svg/image-x-generic", # jpg, jpe, jpeg
74 "./tango-svg/format-indent-more", # m3u
75 "./mint-x-svg/gnome-glchess", # pgn
76 "./tango-svg/dialog-information", # zzz
77);
78
61 79
80my $help;
81my $do_viewers;
82my $tangopath="";
83my $size;
84my @list = @iconlist;
85my $output = "tango_icons";
62 86
63if($#ARGV < 1) { 87GetOptions ( 'v' => \$do_viewers,
64 print "Usage: $0 <path to iconset> <size>\n"; 88 't|tango-path=s' => \$tangopath,
89 'o|output=s' => \$output,
90 'h|help' => \$help,
91 );
92
93if($#ARGV != 0 or $help) {
94 print "Usage: $0 [-v] [-t <path to iconset>] [-o <output prefix>] SIZE\n";
95 print "\n";
96 print "\t-v\tGenerate viewer icons\n";
97 print "\t-t\tPath to source of tango iconset if required\n";
98 print "\t-t\tPath to source of tango iconset if required\n";
99 print "\t-o\tUse <output prefix> instead of \"tango_icons\" for the output filename\n";
100 print "\n";
101 print "\tSIZE can be in the form of NN or NNxNN and will be used for the output filename\n";
65 exit(); 102 exit();
66} 103}
67my $tangopath = $ARGV[0];
68my $size = $ARGV[1];
69 104
105
106$size = $ARGV[0];
107
108if ($do_viewers) {
109 $output .= "_viewers";
110 @list = @iconlist_viewers;
111}
70# temporary files 112# temporary files
71my $alphatemp = File::Temp->new(SUFFIX => ".png"); 113my $alphatemp = File::Temp->new(SUFFIX => ".png");
72my $alphatempfname = $alphatemp->filename(); 114my $alphatempfname = $alphatemp->filename();
@@ -75,7 +117,7 @@ my $exporttempfname = $exporttemp->filename();
75my $tempstrip = File::Temp->new(SUFFIX => ".png"); 117my $tempstrip = File::Temp->new(SUFFIX => ".png");
76my $tempstripfname = $tempstrip->filename(); 118my $tempstripfname = $tempstrip->filename();
77 119
78my $newoutput = "tango_icons.$size.bmp"; 120my $newoutput = "$output.$size.bmp";
79 121
80if(-e $newoutput) { 122if(-e $newoutput) {
81 die("output file $newoutput does already exist!"); 123 die("output file $newoutput does already exist!");
@@ -85,23 +127,29 @@ print "Creating icon strip as $newoutput\n\n";
85 127
86my $count; 128my $count;
87$count = 0; 129$count = 0;
88foreach(@iconlist) { 130
131foreach(@list) {
89 print "processing $_ ...\n"; 132 print "processing $_ ...\n";
90 my $file; 133 my $file;
91 if(m/^$/) { 134 if(m/^$/) {
92 # if nothing is defined make it empty / transparent 135 # if nothing is defined make it empty / transparent
93 my $s = $size . "x" . $size; 136 my $s = $size . "x" . $size;
94 `convert -size $s xc:"#f0f" $exporttempfname` 137 `convert -size $s xc:"#ff00ff" -alpha transparent $exporttempfname`
95 } 138 }
96 elsif(m/\.\./) { 139 elsif(m/\./) {
97 # icon is inside the Rockbox tree 140 # icon is inside the Rockbox tree
98 $file = $_; 141 $file = $_ . ".svg";
99 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file` 142 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
100 } 143 }
101 else { 144 else {
102 # icon is inside the tango tree 145 # icon is inside the tango tree
146 if ($tangopath eq "") {
147 print "Path to tango sources needed but not given!\n";
148 exit(1);
149 }
103 $file = "$tangopath/scalable/" . $_ . ".svg"; 150 $file = "$tangopath/scalable/" . $_ . ".svg";
104 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file` 151 #~ `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
152 `cp $file tango-svg/`;
105 } 153 }
106 if($count != 0) { 154 if($count != 0) {
107 `convert -append $tempstripfname $exporttempfname $tempstripfname`; 155 `convert -append $tempstripfname $exporttempfname $tempstripfname`;
@@ -111,10 +159,7 @@ foreach(@iconlist) {
111 } 159 }
112 $count++; 160 $count++;
113} 161}
114print "masking and converting result ...\n"; 162print "Converting result ...\n";
115# create mask 163`convert $tempstripfname $newoutput`;
116`convert $tempstripfname -alpha extract -monochrome -negate -alpha copy -colorize 0,100,0 $alphatempfname`; 164print "Done!\n";
117# combine mask with image and drop transparency and scale down
118`convert -composite $tempstripfname $alphatempfname -flatten -background '#f0f' -alpha off $newoutput`;
119print "done!\n";
120 165