Class: Colors::HSLA
- Inherits:
-
HSL
- Object
- AbstractColor
- HSL
- Colors::HSLA
- Includes:
- AlphaComponent
- Defined in:
- lib/colors/hsla.rb
Instance Attribute Summary
Attributes included from AlphaComponent
Attributes inherited from HSL
Instance Method Summary collapse
- #==(other) ⇒ Object
- #components ⇒ Object (also: #hsla_components)
- #desaturate(factor) ⇒ Object
-
#initialize(h, s, l, a) ⇒ HSLA
constructor
A new instance of HSLA.
- #to_hsl ⇒ Object
- #to_hsla ⇒ Object
- #to_rgb ⇒ Object
- #to_rgba ⇒ Object
Methods inherited from HSL
Methods inherited from AbstractColor
Constructor Details
#initialize(h, s, l, a) ⇒ HSLA
Returns a new instance of HSLA.
3 4 5 |
# File 'lib/colors/hsla.rb', line 3 def initialize(h, s, l, a) @h, @s, @l, @a = canonicalize(h, s, l, a) end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/colors/hsla.rb', line 15 def ==(other) case other when HSLA h == other.h && s == other.s && l == other.l && a == other.a when HSL h == other.h && s == other.s && l == other.l && a == 1r else super end end |
#components ⇒ Object Also known as: hsla_components
9 10 11 |
# File 'lib/colors/hsla.rb', line 9 def components [h, s, l, a] end |
#desaturate(factor) ⇒ Object
26 27 28 |
# File 'lib/colors/hsla.rb', line 26 def desaturate(factor) HSLA.new(h, s*factor, l, a) end |
#to_hsl ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/colors/hsla.rb', line 38 def to_hsl if a == 1r super else raise NotImplementedError, "Unable to convert non-opaque HSLA to HSL" end end |
#to_hsla ⇒ Object
30 31 32 |
# File 'lib/colors/hsla.rb', line 30 def to_hsla self end |
#to_rgb ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/colors/hsla.rb', line 47 def to_rgb if a == 1r super else raise NotImplementedError, "Unable to convert non-opaque HSLA to RGB" end end |