class RubyXL::ColorConvenienceClasses::HlsColor

def apply_tint(tint)

def apply_tint(tint)
  return self if tint.nil? || tint == 0
  if tint < 0 then
    self.l = l * (1.0 + tint);
  else
    self.l = l * (1.0 - tint) + tint;
  end
  self
end

def set_color(t1, t2, t3)

def set_color(t1, t2, t3)
  color = 0
  t3 += 1.0 if (t3 < 0)
  t3 -= 1.0 if (t3 > 1)
  if (6.0 * t3 < 1) then
    color = t2 + (t1 - t2) * 6.0 * t3;
  elsif (2.0 * t3 < 1) then
    color = t1;
  elsif (3.0 * t3 < 2) then
    color = t2 + (t1 - t2) * ((2.0 / 3.0) - t3) * 6.0;
  else
    color = t2;
  end
  color
end

def to_rgb

def to_rgb
  rgb_color = RgbColor.new
  r = g = b = l
  if s != 0 then
    t1 = nil
    if l < 0.5 then
      t1 = l * (1.0 + s)
    else
      t1 = l + s - (l * s)
    end
    t2 = 2.0 * l - t1;
    h = self.h / 360.0
    t_r = h + (1.0 / 3.0)
    r = set_color(t1, t2, t_r)
    t_g = h;
    g = set_color(t1, t2, t_g)
    t_b = h - (1.0 / 3.0);
    b = set_color(t1, t2, t_b)
  end
  rgb_color.r = (r * 255).round(0).to_i
  rgb_color.g = (g * 255).round(0).to_i
  rgb_color.b = (b * 255).round(0).to_i
  rgb_color.a = (a * 255).round(0).to_i
  rgb_color
end