class Recolor::Recolor

Attributes

converter[RW]
models[RW]

Public Class Methods

new() click to toggle source
# File lib/recolor.rb, line 19
def initialize
  @models = {}
  @models[:hex] = Models::Hex.new
  @models[:hpluv] = Models::HPLuv.new
  @models[:hsluv] = Models::HSLuv.new
  @models[:lch] = Models::LCh.new
  @models[:luv] = Models::Luv.new
  @models[:rgb] = Models::RGB.new
  @models[:xyz] = Models::XYZ.new
  @converter = Converter.new
  @converter.models[:hex] = @models[:hex]
  @converter.models[:hpluv] = @models[:hpluv]
  @converter.models[:hsluv] = @models[:hsluv]
  @converter.models[:lch] = @models[:lch]
  @converter.models[:luv] = @models[:luv]
  @converter.models[:rgb] = @models[:rgb]
  @converter.models[:xyz] = @models[:xyz]
end

Public Instance Methods

color(model, tuple) click to toggle source
# File lib/recolor.rb, line 38
def color(model, tuple)
  @color = Color.new(model, tuple)

  return self.clone
end
format() { |tuple| ... } click to toggle source
# File lib/recolor.rb, line 62
def format
  yield @color.tuple
end
model() click to toggle source
# File lib/recolor.rb, line 54
def model
  return @color.model
end
to(model) click to toggle source
# File lib/recolor.rb, line 44
def to(model)
  raise Exception.new("Color definition not found.") unless @color

  source = @color.model
  tuple = @color.tuple
  tuple = @converter.convert(tuple, source, model)

  return color(model, tuple)
end
to_s() click to toggle source
# File lib/recolor.rb, line 66
def to_s
  return @models[model].print(tuple)
end
tuple() click to toggle source
# File lib/recolor.rb, line 58
def tuple
  return @color.tuple
end