module Sass::Script::Functions
def hsla(hue, saturation, lightness, alpha)
-
(ArgumentError)
- if `saturation`, `lightness`, or `alpha` are out of bounds
Other tags:
- See: #hsl -
Returns:
-
(Color)
- The resulting color
Parameters:
-
alpha
(Number
) -- The opacity of the color. -
lightness
(Number
) -- The lightness of the color. -
saturation
(Number
) -- The saturation of the color. -
hue
(Number
) -- The hue of the color.
def hsla(hue, saturation, lightness, alpha) assert_type hue, :Number assert_type saturation, :Number assert_type lightness, :Number assert_type alpha, :Number unless (0..1).include?(alpha.value) raise ArgumentError.new("Alpha channel #{alpha.value} must be between 0 and 1") end original_s = saturation original_l = lightness # This algorithm is from http://www.w3.org/TR/css3-color#hsl-color h, s, l = [hue, saturation, lightness].map { |a| a.value } raise ArgumentError.new("Saturation #{s} must be between 0% and 100%") unless (0..100).include?(s) raise ArgumentError.new("Lightness #{l} must be between 0% and 100%") unless (0..100).include?(l) Color.new(:hue => h, :saturation => s, :lightness => l, :alpha => alpha.value) end