Method: Sass::Script::Functions#hsla

Defined in:
lib/sass/script/functions.rb

#hsla($hue, $saturation, $lightness, $alpha) ⇒ Color

Creates a Color from hue, saturation, lightness, and alpha values. Uses the algorithm from the CSS3 spec.

Parameters:

  • $hue (Number)

    The hue of the color. Should be between 0 and 360 degrees, inclusive

  • $saturation (Number)

    The saturation of the color. Must be between 0% and 100%, inclusive

  • $lightness (Number)

    The lightness of the color. Must be between 0% and 100%, inclusive

  • $alpha (Number)

    The opacity of the color. Must be between 0 and 1, inclusive

Returns:

Raises:

  • (ArgumentError)

    if $saturation, $lightness, or $alpha are out of bounds or any parameter is the wrong type

See Also:



482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/sass/script/functions.rb', line 482

def hsla(hue, saturation, lightness, alpha)
  assert_type hue, :Number, :hue
  assert_type saturation, :Number, :saturation
  assert_type lightness, :Number, :lightness
  assert_type alpha, :Number, :alpha

  Sass::Util.check_range('Alpha channel', 0..1, alpha)

  h = hue.value
  s = Sass::Util.check_range('Saturation', 0..100, saturation, '%')
  l = Sass::Util.check_range('Lightness', 0..100, lightness, '%')

  Color.new(:hue => h, :saturation => s, :lightness => l, :alpha => alpha.value)
end