Module: NitroRails::ColorHelper
- Defined in:
- app/helpers/nitro_rails/color_helper.rb
Instance Method Summary collapse
Instance Method Details
#brightness(color) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/helpers/nitro_rails/color_helper.rb', line 14 def brightness(color) if color&.start_with?("#") r = color[1..2].to_i(16) g = color[3..4].to_i(16) b = color[5..6].to_i(16) (r * 299 + g * 587 + b * 114) / 1000 end end |
#brightness_indicator(color) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/nitro_rails/color_helper.rb', line 3 def brightness_indicator(color) case brightness(color) when 0..100 "dark" when 101..200 "medium" else "light" end end |