Method: Pixelart::Color.parse
- Defined in:
- lib/pixelart/color.rb
.parse(color) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pixelart/color.rb', line 11 def self.parse( color ) if color.is_a?( Integer ) ## e.g. assumes ChunkyPNG::Color.rgb() or such color ## pass through as is 1:1 elsif color.is_a?( Array ) ## assume array of hsl(a) e. g. [180, 0.86, 0.88] from_hsl( *color ) elsif color.is_a?( String ) if color.downcase == 'transparent' ## special case for builtin colors TRANSPARENT else ## note: return an Integer !!! (not a Color class or such!!! ) from_hex( color ) end else raise ArgumentError, "unknown color format; cannot parse - expected rgb hex string e.g. d3d3d3" end end |