84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# 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
|