Class: Chroma::RgbGenerator::FromRgbValues
- Defined in:
- lib/chroma/rgb_generator/from_rgb_values.rb
Instance Method Summary collapse
-
#generate ⇒ ColorModes::Rgb
Generates a ColorModes::Rgb.
-
#initialize(format, r, g, b, a = 1) ⇒ FromRgbValues
constructor
A new instance of FromRgbValues.
Methods included from Helpers::Bounders
#bound01, #bound_alpha, #clamp01, #to_percentage
Constructor Details
#initialize(format, r, g, b, a = 1) ⇒ FromRgbValues
Returns a new instance of FromRgbValues.
9 10 11 12 |
# File 'lib/chroma/rgb_generator/from_rgb_values.rb', line 9 def initialize(format, r, g, b, a = 1) @format = format || :rgb @r, @g, @b, @a = r, g, b, a end |
Instance Method Details
#generate ⇒ ColorModes::Rgb
Generates a ColorModes::Rgb.
16 17 18 19 20 |
# File 'lib/chroma/rgb_generator/from_rgb_values.rb', line 16 def generate r, g, b = [@r, @g, @b].map { |n| bound01(n, 255) * 255 } a = bound_alpha(@a) [ColorModes::Rgb.new(r, g, b, a), @format] end |