module Silicium::Plotter
Public Instance Methods
color(*args)
click to toggle source
Factory method to return a color value, based on the arguments given.
@overload Color(r, g, b, a)
@param (see ChunkyPNG::Color.rgba) @return [Integer] The rgba color value.
@overload Color(r, g, b)
@param (see ChunkyPNG::Color.rgb) @return [Integer] The rgb color value.
@overload Color(hex_value, opacity = nil)
@param (see ChunkyPNG::Color.from_hex) @return [Integer] The hex color value, with the opacity applied if one was given.
@overload Color(color_name, opacity = nil)
@param (see ChunkyPNG::Color.html_color) @return [Integer] The hex color value, with the opacity applied if one was given.
@overload Color(color_value, opacity = nil)
@param [Integer, :to_i] The color value. @return [Integer] The color value, with the opacity applied if one was given.
@return [Integer] The determined color value as RGBA integer. @raise [ArgumentError] if the arguments weren't understood as a color.
# File lib/plotter.rb, line 34 def color(*args) case args.length when 1; ChunkyPNG::Color.parse(args.first) when 2; (ChunkyPNG::Color.parse(args.first) & 0xffffff00) | args[1].to_i when 3; ChunkyPNG::Color.rgb(*args) when 4; ChunkyPNG::Color.rgba(*args) else raise ArgumentError, "Don't know how to create a color from #{args.inspect}!" end end