class RubyXL::ColorConvenienceClasses::HlsColor
Attributes
Public Instance Methods
Source
# File lib/rubyXL/convenience_methods/color.rb, line 140 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
Source
# File lib/rubyXL/convenience_methods/color.rb, line 84 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