Module: ColorContrastCalc::Converter
- Defined in:
- lib/color_contrast_calc/converter.rb
Overview
Collection of modules that implement the main logic of instance methods of Color, Color#new_*_color().
Defined Under Namespace
Modules: AlphaCompositing, Brightness, Contrast, Grayscale, HueRotate, Invert, Saturate
Class Method Summary collapse
-
.rgb_map(vals) ⇒ Array<Integer>
Values given as an array are passed to a given block, and new values returned from the block are rounded and clamped between 0 and 255, so that the resulting values can be treated as an RGB value.
Class Method Details
.rgb_map(vals) ⇒ Array<Integer>
Values given as an array are passed to a given block, and new values returned from the block are rounded and clamped between 0 and 255, so that the resulting values can be treated as an RGB value.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/color_contrast_calc/converter.rb', line 21 def self.rgb_map(vals) if block_given? return vals.map do |val| new_val = yield val new_val.round.clamp(0, 255) end end vals.map {|val| val.round.clamp(0, 255) } end |