module ChunkyPNG

def self.Color(*args)

Raises:
  • (ChunkyPNG::ExpectationFailed) - if the arguments weren't understood as a color.

Returns:
  • (Integer) - The color value, with the opacity applied if one was given.
  • (Integer) - The hex color value, with the opacity applied if one was given.
  • (Integer) - The hex color value, with the opacity applied if one was given.
  • (Integer) - The rgb color value.
  • (Integer) - The rgba color value.

Parameters:
  • The (Integer, :to_i) -- color value.
  • () --
  • () --
  • () --
  • () --

Overloads:
  • Color(color_value, opacity = nil)
  • Color(color_name, opacity = nil)
  • Color(hex_value, opacity = nil)
  • Color(r, g, b)
  • Color(r, g, b, a)
def self.Color(*args)
  case args.length
    when 4; ChunkyPNG::Color.rgba(*args)
    when 3; ChunkyPNG::Color.rgb(*args)
    when 2; (ChunkyPNG::Color(args[0]) & 0xffffff00) | args[1].to_i
    when 1
      case source = args.first.to_s
        when Integer, /^\d+$/; source.to_i
        when ChunkyPNG::Color::HEX_COLOR_REGEXP;  ChunkyPNG::Color.from_hex(source)
        when ChunkyPNG::Color::HTML_COLOR_REGEXP; ChunkyPNG::Color.html_color(source)
        else raise ChunkyPNG::ExpectationFailed; "Don't know how to create a color from #{source.inspect}!"
      end
    else raise ChunkyPNG::ExpectationFailed; "Don't know how to create a color from #{args.inspect}!"
  end
end