daemon: Fix #33
[ladish.git] / art / render-bitmaps.rb
blobe0bd1c94e1047045659a26943dcd3539b2ec3f2b
1 #!/usr/bin/env ruby
3 require "rexml/document"
4 require "ftools"
5 include REXML
6 INKSCAPE = 'env inkscape'
7 SRC = "#{Dir.pwd}/src"
9 puts "Rendering from SVGs in #{SRC}"
10 Dir.foreach(SRC) do |file|
11   if file.match(/svg$/)
12     svg = Document.new(File.new("#{SRC}/#{file}", 'r'))
13     svg.root.each_element("//g[@inkscape:label='baseplate']/rect") do |icon|
14       dir = "#{icon.attributes['inkscape:label']}/apps"
15       File.makedirs(dir) unless File.exists?(dir)
16       out = "#{dir}/#{file.gsub(/svg$/,"png")}"
17       cmd = "#{INKSCAPE} -i #{icon.attributes['id']} -e #{Dir.pwd}/#{out} #{SRC}/#{file} > /dev/null 2>&1"
18       system(cmd)
19       print "."
20       #puts cmd
21     end
22   end
23 end
24 puts "done rendering"