Skip to content

Instantly share code, notes, and snippets.

@japgolly
Created February 8, 2013 00:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save japgolly/4735584 to your computer and use it in GitHub Desktop.
Save japgolly/4735584 to your computer and use it in GitHub Desktop.
DENSITIES= {
'-mdpi' => 1.0,
'-ldpi' => 0.75,
'-hdpi' => 1.5,
'-xhdpi' => 2.0,
}
def run_cmd(cmd)
puts cmd
system cmd
raise unless $?.success?
end
# Inc/Dec buttons
if ARGV.include?('incdec')
DENSITIES.each {|dname, dfactor|
density= 38*dfactor
%w[inc dec].each {|name|
%w[default pressed].each{|state|
svg= "btn_#{name}_#{state}.svg"
out= "res/drawable#{dname}/btn_#{name}_#{state}.png"
run_cmd "convert -background none -density #{density} #{svg} PNG32:#{out}"
}
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment