summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-03-14 16:32:55 -0700
committerelijah <elijah@riseup.net>2013-03-14 16:32:55 -0700
commit74769dcc8ab6a1bb2e505fe680b315bed0c85855 (patch)
tree91d8a265e8ed5790fc7cab3edd8ae71133790700 /Rakefile
parent46d44328f239d1801fbef0135968023a23d2a612 (diff)
added favicon
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile55
1 files changed, 34 insertions, 21 deletions
diff --git a/Rakefile b/Rakefile
index 25a994b..9109b63 100644
--- a/Rakefile
+++ b/Rakefile
@@ -21,7 +21,8 @@ output_directories = [
'qt/dark/64',
'qt/light/16',
'qt/light/32',
- 'qt/light/64'
+ 'qt/light/64',
+ 'web'
]
android_launcher_target = [
@@ -71,7 +72,8 @@ svg_to_png = [
['svg/qt/dark/*.svg', qt_dark_icon_target],
['svg/qt/light/*.svg', qt_light_icon_target],
['svg/android/leap-launcher.svg', {:size => 128, :dest => 'mac/leap-128x128.png'}],
- ['svg/kid-jumping.svg', {:width => 128, :dest => 'qt/leap-small.png'}]
+ ['svg/kid-jumping.svg', {:width => 128, :dest => 'qt/leap-small.png'}],
+ ['svg/kid-jumping-bw.svg', {:size => 16, :dest => 'web/favicon.png'}]
]
png_to_icns = [
@@ -94,24 +96,26 @@ end
def render_svg_to_png(source, targets)
Dir.glob(source).each do |src_file|
[targets].flatten.each do |target|
- dest_file = if File.directory?(target[:dest])
- File.join(target[:dest], File.basename(src_file).sub(/\.svg$/,'.png'))
+ if File.directory?(target[:dest])
+ dest_file = File.join(target[:dest], File.basename(src_file).sub(/\.svg$/,'.png'))
else
- target[:dest]
+ dest_file = target[:dest]
end
- if target[:size]
- height = width = target[:size]
- else
- height = target[:height]
- width = target[:width]
+ if !File.exists?(dest_file) || File.mtime(dest_file) < File.mtime(src_file)
+ if target[:size]
+ height = width = target[:size]
+ else
+ height = target[:height]
+ width = target[:width]
+ end
+ options = ["--file=#{src_file}", "--export-png=#{dest_file}", "--export-background=0xffffff", "--export-background-opacity=0x00"]
+ options << "-w #{width}" if width
+ options << "-h #{height}" if height
+ options << "--export-dpi=#{target[:dpi]}" if target[:dpi]
+ run("inkscape #{options.join ' '}")
+ run("optipng #{dest_file}")
+ progress
end
- options = ["--file=#{src_file}", "--export-png=#{dest_file}", "--export-background=0xffffff", "--export-background-opacity=0x00"]
- options << "-w #{width}" if width
- options << "-h #{height}" if height
- options << "--export-dpi=#{target[:dpi]}" if target[:dpi]
- run("inkscape #{options.join ' '}")
- run("optipng #{dest_file}")
- progress
end
end
end
@@ -134,14 +138,11 @@ require 'fileutils'
task :default => :render
-desc "render SVG images to PNGs"
+desc "render SVG images"
task :render do
Dir.chdir(File.dirname(__FILE__)) do
output_directories.each do |dir|
FileUtils.mkdir_p(dir)
- Dir.entries(dir).grep(/\.(png|icns|jpg)$/).each do |file|
- File.unlink File.join(dir,file)
- end
end
svg_to_png.each do |source, targets|
render_svg_to_png(source, targets)
@@ -152,3 +153,15 @@ task :render do
end
puts
end
+
+desc "clean out rendered images"
+task :clean do
+ Dir.chdir(File.dirname(__FILE__)) do
+ output_directories.each do |dir|
+ Dir.entries(dir).grep(/\.(png|icns|jpg)$/).each do |file|
+ File.unlink File.join(dir,file)
+ end
+ end
+ end
+end
+