Sha256: 465f906217ee21f2e831be3c918fb5835fe4370dd2a9038ff0c133ae2be05cb5
Contents?: true
Size: 572 Bytes
Versions: 2
Compression:
Stored size: 572 Bytes
Contents
module RGBUtils class SimpleContrastColorResolver < Resolver THRESHOLD_VALUE = 186/255.0 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 luma > THRESHOLD_VALUE light_color end end private attr_reader :color, :light_color, :dark_color def luma @luma ||= LumaCalculator.calculate(color) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rgb_utils-0.1.2 | lib/rgb_utils/resolvers/simple_contrast_color_resolver.rb |
rgb_utils-0.1.1 | lib/rgb_utils/resolvers/simple_contrast_color_resolver.rb |