Module: Chroma::Color::Attributes
- Included in:
- Chroma::Color
- Defined in:
- lib/chroma/color/attributes.rb
Overview
Attribute methods for Chroma::Color.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
-
#alpha ⇒ Float
Returns the alpha channel value.
-
#brightness ⇒ Float
Calculates the brightness.
-
#dark? ⇒ true, false
Determines if the color is dark.
-
#light? ⇒ true, false
Determines if the color is light.
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/chroma/color/attributes.rb', line 5 def format @format end |
Instance Method Details
#alpha ⇒ Float
Returns the alpha channel value.
36 37 38 |
# File 'lib/chroma/color/attributes.rb', line 36 def alpha @rgb.a end |
#brightness ⇒ Float
Calculates the brightness.
47 48 49 |
# File 'lib/chroma/color/attributes.rb', line 47 def brightness (@rgb.r * 299 + @rgb.g * 587 + @rgb.b * 114) / 1000.0 end |
#dark? ⇒ true, false
Determines if the color is dark.
14 15 16 |
# File 'lib/chroma/color/attributes.rb', line 14 def dark? brightness < 128 end |
#light? ⇒ true, false
Determines if the color is light.
25 26 27 |
# File 'lib/chroma/color/attributes.rb', line 25 def light? !dark? end |