class RGBUtils::SimpleContrastColorResolver
Constants
- THRESHOLD_VALUE
Attributes
color[R]
dark_color[R]
light_color[R]
Public Class Methods
new(color, options = {})
click to toggle source
# File lib/rgb_utils/resolvers/simple_contrast_color_resolver.rb, line 5 def initialize(color, options = {}) @color = color @light_color = options.fetch(:light_color, Config.light_color) @dark_color = options.fetch(:dark_color, Config.dark_color) end
Public Instance Methods
for()
click to toggle source
# File lib/rgb_utils/resolvers/simple_contrast_color_resolver.rb, line 11 def for @result ||= begin return dark_color if luma > THRESHOLD_VALUE light_color end end
Private Instance Methods
luma()
click to toggle source
# File lib/rgb_utils/resolvers/simple_contrast_color_resolver.rb, line 23 def luma @luma ||= LumaCalculator.calculate(color) end