Sha256: 8a1860ca01b2c97b29d96b5a1d0197cad3adfd3f2ac8ee7722fefbf0a5c80eb4
Contents?: true
Size: 640 Bytes
Versions: 2
Compression:
Stored size: 640 Bytes
Contents
module RGBUtils class ComplexContrastColorResolver < Resolver 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 def for @result ||= begin return dark_color if luminance > luminance_cutoff light_color end end private attr_reader :color, :light_color, :dark_color def luminance @luminance ||= RelativeLuminanceCalculator.calculate(color) end def luminance_cutoff Math::sqrt(1.05 * 0.05) - 0.05 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rgb_utils-0.1.2 | lib/rgb_utils/resolvers/complex_contrast_color_resolver.rb |
rgb_utils-0.1.1 | lib/rgb_utils/resolvers/complex_contrast_color_resolver.rb |