File: render-bitmaps.rb

package info (click to toggle)
ladish 1%2Bdfsg0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,940 kB
  • sloc: ansic: 36,406; python: 11,237; cpp: 705; makefile: 22; ruby: 20; sh: 17
file content (24 lines) | stat: -rwxr-xr-x 699 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env ruby

require "rexml/document"
require "ftools"
include REXML
INKSCAPE = 'env inkscape'
SRC = "#{Dir.pwd}/src"

puts "Rendering from SVGs in #{SRC}"
Dir.foreach(SRC) do |file|
  if file.match(/svg$/)
    svg = Document.new(File.new("#{SRC}/#{file}", 'r'))
    svg.root.each_element("//g[@inkscape:label='baseplate']/rect") do |icon|
      dir = "#{icon.attributes['inkscape:label']}/apps"
      File.makedirs(dir) unless File.exists?(dir)
      out = "#{dir}/#{file.gsub(/svg$/,"png")}"
      cmd = "#{INKSCAPE} -i #{icon.attributes['id']} -e #{Dir.pwd}/#{out} #{SRC}/#{file} > /dev/null 2>&1"
      system(cmd)
      print "."
      #puts cmd
    end
  end
end
puts "done rendering"