Method: Sass::Script::Value::Helpers#rgb_color

Defined in:
lib/sass/script/value/helpers.rb

#rgb_color(red, green, blue, alpha = nil) ⇒ Sass::Script::Value::Color

Construct a Sass Color from rgb values.

Parameters:

  • red (::Number)

    The red component. Must be between 0 and 255 inclusive.

  • green (::Number)

    The green component. Must be between 0 and 255 inclusive.

  • blue (::Number)

    The blue component. Must be between 0 and 255 inclusive.

  • alpha (::Number) (defaults to: nil)

    The alpha channel. A number between 0 and 1.

Returns:

Since:

  • 3.3.0


48
49
50
51
52
# File 'lib/sass/script/value/helpers.rb', line 48

def rgb_color(red, green, blue, alpha = nil)
  attrs = {:red => red, :green => green, :blue => blue}
  attrs[:alpha] = alpha if alpha
  Color.new(attrs)
end