Class: Chroma::RgbGenerator::FromHslValues

Inherits:
Base
  • Object
show all
Defined in:
lib/chroma/rgb_generator/from_hsl_values.rb

Instance Method Summary collapse

Methods included from Helpers::Bounders

#bound01, #bound_alpha, #clamp01, #to_percentage

Constructor Details

#initialize(format, h, s, l, a = 1) ⇒ FromHslValues

Returns a new instance of FromHslValues

Parameters:

  • format (Symbol)

    color format

  • h (String, Numeric)

    hue value

  • s (String, Numeric)

    saturation value

  • l (String, Numeric)

    lightness value

  • a (String, Numeric) (defaults to: 1)

    alpha value


9
10
11
12
13
14
15
# File 'lib/chroma/rgb_generator/from_hsl_values.rb', line 9

def initialize(format, h, s, l, a = 1)
  s = to_percentage(s)
  l = to_percentage(l)

  @format = format || :hsl
  @hsl = ColorModes::Hsl.new(h, s, l, a)
end

Instance Method Details

#generateColorModes::Rgb

Generates a ColorModes::Rgb.

Returns:


19
20
21
# File 'lib/chroma/rgb_generator/from_hsl_values.rb', line 19

def generate
  [Converters::RgbConverter.convert_hsl(@hsl), @format]
end