Top Level Namespace
Instance Method Summary collapse
- #colors_hash_from_plist(plist_content) ⇒ Object
- #colors_hash_from_plist_files(plist_files) ⇒ Object
- #generate_png(colors_hash) ⇒ Object
Instance Method Details
#colors_hash_from_plist(plist_content) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/plist_colors.rb', line 30 def colors_hash_from_plist(plist_content) colors_hash = {} plist_content.each do |key, value| if key.downcase == "colors" then colors_hash = colors_hash.merge(value) elsif value.is_a?(Hash) sub_hash = colors_hash_from_plist(value) colors_hash = colors_hash.merge(sub_hash) end end colors_hash end |
#colors_hash_from_plist_files(plist_files) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/plist_colors.rb', line 43 def colors_hash_from_plist_files(plist_files) colors_hash = {} plist_files.each do |plist_file| content = Plist::parse_xml(plist_file) plist_colors = colors_hash_from_plist(content) colors_hash = colors_hash.merge(plist_colors) end colors_hash end |
#generate_png(colors_hash) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/plist_colors.rb', line 4 def generate_png(colors_hash) colors_path = 'colors' FileUtils.rm_rf colors_path FileUtils.mkdir colors_path montages = [] colors_hash.each do |key, value| image_path = "#{colors_path}/#{key}.png" image_key_path = "#{colors_path}/#{key}_text_key.png" image_value_path = "#{colors_path}/#{key}_text_value.png" image_result_path = "#{colors_path}/#{key}_montage.png" `convert -size 100x100 xc:##{value} #{image_path}` `convert -background white -pointsize 22 caption:#{key} #{image_key_path}` `convert -background white -pointsize 22 caption:#{value} #{image_value_path}` `montage #{image_path} #{image_key_path} #{image_value_path} -tile x1 -geometry +5+5 #{image_result_path}` montages << image_result_path end all_paths = montages.join " " `montage #{all_paths} -tile 1x -geometry +5+5 color_mapping.png` FileUtils.rm_rf colors_path end |