Method: Pixelart::Image.parse_colors
- Defined in:
- lib/pixelart/image.rb
.parse_colors(colors) ⇒ Object
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/pixelart/image.rb', line 406 def self.parse_colors( colors ) if colors.is_a?( Array ) ## convenience shortcut ## note: always auto-add color 0 as pre-defined transparent - why? why not? h = { '0' => Color::TRANSPARENT } colors.each_with_index do |color, i| h[ (i+1).to_s ] = Color.parse( color ) end h else ## assume hash table with color map ## convert into ChunkyPNG::Color colors.map do |key,color| ## always convert key to string why? why not? use symbol? [ key.to_s, Color.parse( color ) ] end.to_h end end |