Class: RGBUtils::ComplexContrastColorResolver

Inherits:
Resolver
  • Object
show all
Defined in:
lib/rgb_utils/resolvers/complex_contrast_color_resolver.rb

Instance Method Summary collapse

Methods inherited from Resolver

for

Constructor Details

#initialize(color, options = {}) ⇒ ComplexContrastColorResolver

Returns a new instance of ComplexContrastColorResolver.



3
4
5
6
7
# File 'lib/rgb_utils/resolvers/complex_contrast_color_resolver.rb', line 3

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

Instance Method Details

#forObject



9
10
11
12
13
14
15
# File 'lib/rgb_utils/resolvers/complex_contrast_color_resolver.rb', line 9

def for
  @result ||= begin
    return dark_color if luminance > luminance_cutoff

    light_color
  end
end