source: trip-planner-front/node_modules/stylus/lib/functions/hsla.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[6a3a178]1var utils = require('../utils')
2 , nodes = require('../nodes');
3
4/**
5 * Convert the given `color` to an `HSLA` node,
6 * or h,s,l,a component values.
7 *
8 * Examples:
9 *
10 * hsla(10deg, 50%, 30%, 0.5)
11 * // => HSLA
12 *
13 * hsla(#ffcc00)
14 * // => HSLA
15 *
16 * @param {RGBA|HSLA|Unit} hue
17 * @param {Unit} saturation
18 * @param {Unit} lightness
19 * @param {Unit} alpha
20 * @return {HSLA}
21 * @api public
22 */
23
24function hsla(hue, saturation, lightness, alpha){
25 switch (arguments.length) {
26 case 1:
27 utils.assertColor(hue);
28 return hue.hsla;
29 case 2:
30 utils.assertColor(hue);
31 var color = hue.hsla;
32 utils.assertType(saturation, 'unit', 'alpha');
33 var alpha = saturation.clone();
34 if ('%' == alpha.type) alpha.val /= 100;
35 return new nodes.HSLA(
36 color.h
37 , color.s
38 , color.l
39 , alpha.val);
40 default:
41 utils.assertType(hue, 'unit', 'hue');
42 utils.assertType(saturation, 'unit', 'saturation');
43 utils.assertType(lightness, 'unit', 'lightness');
44 utils.assertType(alpha, 'unit', 'alpha');
45 var alpha = alpha.clone();
46 if (alpha && '%' == alpha.type) alpha.val /= 100;
47 return new nodes.HSLA(
48 hue.val
49 , saturation.val
50 , lightness.val
51 , alpha.val);
52 }
53};
54hsla.params = ['hue', 'saturation', 'lightness', 'alpha'];
55module.exports = hsla;
Note: See TracBrowser for help on using the repository browser.