Module: Chroma::RgbGenerator

Defined in:
lib/chroma/rgb_generator.rb,
lib/chroma/rgb_generator/base.rb,
lib/chroma/rgb_generator/from_hsl.rb,
lib/chroma/rgb_generator/from_hsv.rb,
lib/chroma/rgb_generator/from_rgb.rb,
lib/chroma/rgb_generator/from_string.rb,
lib/chroma/rgb_generator/from_hsl_values.rb,
lib/chroma/rgb_generator/from_rgb_values.rb,
lib/chroma/rgb_generator/from_hsv_values.rb,
lib/chroma/rgb_generator/from_hex_string_values.rb

Overview

Main module to generate an instance of ColorModes::Rgb from several possible inputs.

Defined Under Namespace

Classes: Base, FromHexStringValues, FromHsl, FromHslValues, FromHsv, FromHsvValues, FromRgb, FromRgbValues, FromString

Class Method Summary collapse

Class Method Details

.generate_rgb_and_format(input) ⇒ [ColorModes::Rgb, Symbol]

Generates an instance of ColorModes::Rgb as well as color format symbol.


11
12
13
14
15
16
17
# File 'lib/chroma/rgb_generator.rb', line 11

def generate_rgb_and_format(input)
  get_generator(input).generate.tap do |(rgb)|
    rgb.r = round(rgb.r)
    rgb.g = round(rgb.g)
    rgb.b = round(rgb.b)
  end
end