module Color
Public Class Methods
new(values, mode = :rgb)
click to toggle source
Provides a thin veneer over the Color
module to make it seem like this is Color
0.1.0 (a class) and not Color
1.4.1 (a module). This “constructor” will be removed in the future.
- mode = :hsl
-
values
must be an array of [ hue deg, sat %, lum % ]. ASpectrum::HSL
object will be created. - mode = :rgb
-
values
will either be an HTML-style colour string or an array of [ red, green, blue ] (range 0 .. 255). ASpectrum::RGB
object will be created. - mode = :cmyk
-
values
must be an array of [ cyan %, magenta %, yellow %, black % ]. ASpectrum::CMYK
object will be created.
# File lib/spectrum.rb, line 128 def self.new(values, mode = :rgb) warn "Color.new has been deprecated. Use Spectrum::#{mode.to_s.upcase}.new instead." color = case mode when :hsl Spectrum::HSL.new(*values) when :rgb values = [ values ].flatten if values.size == 1 Spectrum::RGB.from_html(*values) else Spectrum::RGB.new(*values) end when :cmyk Spectrum::CMYK.new(*values) end color.to_hsl end