Class: ColorMath::HSL
- Inherits:
-
Object
- Object
- ColorMath::HSL
- Includes:
- Color
- Defined in:
- lib/colormath/color/hsl.rb
Overview
A colour represented and stored as hue, saturation and luminance components
Constant Summary
Constants included from Color
Instance Attribute Summary collapse
-
#alpha ⇒ Object
readonly
Returns the value of attribute alpha.
-
#hue ⇒ Object
readonly
Returns the value of attribute hue.
-
#luminance ⇒ Object
readonly
Returns the value of attribute luminance.
-
#saturation ⇒ Object
readonly
Returns the value of attribute saturation.
Instance Method Summary collapse
-
#blue ⇒ Object
The blue component of the colour in RGB representation where 0 <= b <= 1.
-
#green ⇒ Object
The green component of the colour in RGB representation where 0 <= g <= 1.
-
#initialize(h, s, l) ⇒ HSL
constructor
Initialize an HSL colour where: 0 <= h <= 360 0 <= s <= 1 0 <= l <= 1.
-
#red ⇒ Object
The red component of the colour in RGB representation where 0 <= r <= 1.
Methods included from Color
Constructor Details
#initialize(h, s, l) ⇒ HSL
Initialize an HSL colour where:
0 <= h <= 360
0 <= s <= 1
0 <= l <= 1
Values outside these ranges will be clippped.
17 18 19 20 21 |
# File 'lib/colormath/color/hsl.rb', line 17 def initialize(h, s, l) @hue = force_range(h, 0, 360).to_f @saturation = force_range(s, 0, 1).to_f @luminance = force_range(l, 0, 1).to_f end |
Instance Attribute Details
#alpha ⇒ Object (readonly)
Returns the value of attribute alpha.
8 9 10 |
# File 'lib/colormath/color/hsl.rb', line 8 def alpha @alpha end |
#hue ⇒ Object (readonly)
Returns the value of attribute hue.
8 9 10 |
# File 'lib/colormath/color/hsl.rb', line 8 def hue @hue end |
#luminance ⇒ Object (readonly)
Returns the value of attribute luminance.
8 9 10 |
# File 'lib/colormath/color/hsl.rb', line 8 def luminance @luminance end |
#saturation ⇒ Object (readonly)
Returns the value of attribute saturation.
8 9 10 |
# File 'lib/colormath/color/hsl.rb', line 8 def saturation @saturation end |
Instance Method Details
#blue ⇒ Object
The blue component of the colour in RGB representation where 0 <= b <= 1
37 38 39 |
# File 'lib/colormath/color/hsl.rb', line 37 def blue t = component(hk - (1/3.0)) end |
#green ⇒ Object
The green component of the colour in RGB representation where 0 <= g <= 1
31 32 33 |
# File 'lib/colormath/color/hsl.rb', line 31 def green t = component(hk) end |
#red ⇒ Object
The red component of the colour in RGB representation where 0 <= r <= 1
25 26 27 |
# File 'lib/colormath/color/hsl.rb', line 25 def red t = component(hk + (1/3.0)) end |