Module: Color
- Defined in:
- lib/spectrum.rb
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
:nodoc:.
-
.new(values, mode = :rgb) ⇒ Object
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).
Class Method Details
.const_missing(name) ⇒ Object
:nodoc:
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/spectrum.rb', line 102 def self.const_missing(name) #:nodoc: case name when "VERSION", :VERSION, "COLOR_TOOLS_VERSION", :COLOR_TOOLS_VERSION warn "Spectrum::#{name} has been deprecated. Use Spectrum::COLOR_VERSION instead." Spectrum::COLOR_VERSION else if Spectrum::RGB.const_defined?(name) warn "Spectrum::#{name} has been deprecated. Use Spectrum::RGB::#{name} instead." Spectrum::RGB.const_get(name) else super end end end |
.new(values, mode = :rgb) ⇒ Object
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 % ]. A Spectrum::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). A Spectrum::RGB object will be created. - mode = :cmyk
-
values
must be an array of [ cyan %, magenta %, yellow %, black % ]. A Spectrum::CMYK object will be created.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# 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 |