# color class
# $Id: color.rb,v 1.1.1.1 2003/10/29 01:20:42 knok Exp $

class Color
  attr_reader :red, :green, :blue
  def initialize(r, g, b)
    @red = r
    @green = g
    @blue = b
  end
  def to_white(d)
    @red = limit_max(@red + d)
    @green = limit_max(@green + d)
    @blue = limit_max(@blue + d)
  end
  def to_black(d)
    @red = limit_min(@red - d)
    @green = limit_min(@green - d)
    @blue = limit_min(@blue - d)
  end
  def limit_max(i)
    if i > 255
      i = 255
    end
    return i
  end
  def limit_min(i)
    if i < 0
      i = 0
    end
    return i
  end
end
