Class: RubyXL::ColorConvenienceClasses::HlsColor
- Inherits:
-
Object
- Object
- RubyXL::ColorConvenienceClasses::HlsColor
- Defined in:
- lib/rubyXL/convenience_methods.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#h ⇒ Object
Returns the value of attribute h.
-
#l ⇒ Object
Returns the value of attribute l.
-
#s ⇒ Object
Returns the value of attribute s.
Instance Method Summary collapse
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
1228 1229 1230 |
# File 'lib/rubyXL/convenience_methods.rb', line 1228 def a @a end |
#h ⇒ Object
Returns the value of attribute h.
1228 1229 1230 |
# File 'lib/rubyXL/convenience_methods.rb', line 1228 def h @h end |
#l ⇒ Object
Returns the value of attribute l.
1228 1229 1230 |
# File 'lib/rubyXL/convenience_methods.rb', line 1228 def l @l end |
#s ⇒ Object
Returns the value of attribute s.
1228 1229 1230 |
# File 'lib/rubyXL/convenience_methods.rb', line 1228 def s @s end |
Instance Method Details
#apply_tint(tint) ⇒ Object
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
# File 'lib/rubyXL/convenience_methods.rb', line 1286 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 |
#to_rgb ⇒ Object
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
# File 'lib/rubyXL/convenience_methods.rb', line 1230 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 |