Class: Maglev::Content::Color
- Inherits:
-
Base
- Object
- Base
- Maglev::Content::Color
show all
- Defined in:
- app/components/maglev/content/color.rb
Instance Attribute Summary
Attributes inherited from Base
#content, #scope, #setting
Instance Method Summary
collapse
Methods inherited from Base
#asset_host, #dom_data, #initialize, #tag, #tag_data, #tag_id, #to_s
Instance Method Details
#brightness ⇒ Object
14
15
16
17
|
# File 'app/components/maglev/content/color.rb', line 14
def brightness
r, g, b = content.match(/^#(..)(..)(..)$/).captures.map(&:hex)
(r * 299 + g * 587 + b * 114) / 1000.0
end
|
#dark? ⇒ Boolean
6
7
8
|
# File 'app/components/maglev/content/color.rb', line 6
def dark?
brightness < 128
end
|
#light? ⇒ Boolean
10
11
12
|
# File 'app/components/maglev/content/color.rb', line 10
def light?
!dark?
end
|