Class: Chroma::RgbGenerator::FromHsvValues

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

Instance Method Summary collapse

Methods included from Helpers::Bounders

#bound01, #bound_alpha, #clamp01, #to_percentage

Constructor Details

#initialize(format, h, s, v, a = 1) ⇒ FromHsvValues

Returns a new instance of FromHsvValues

Parameters:

  • format (Symbol)

    color format

  • h (String, Numeric)

    hue value

  • s (String, Numeric)

    saturation value

  • v (String, Numeric)

    value value

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

    alpha value


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

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

  @format = format || :hsv
  @hsv = ColorModes::Hsv.new(h, s, v, a)
end

Instance Method Details

#generateColorModes::Rgb

Generates a ColorModes::Rgb.

Returns:


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

def generate
  [Converters::RgbConverter.convert_hsv(@hsv), @format]
end