class Chroma::RgbGenerator::FromRgbValues
Public Class Methods
new(format, r, g, b, a = 1)
click to toggle source
@param format [Symbol] color format @param r [String, Numeric] red value @param g [String, Numeric] green value @param b [String, Numeric] blue value @param a [String, Numeric] alpha value
# 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
Public Instance Methods
generate()
click to toggle source
Generates a {ColorModes::Rgb}. @return [ColorModes::Rgb]
# 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