source: trip-planner-front/node_modules/stylus/lib/functions/alpha.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 748 bytes
Line 
1var nodes = require('../nodes')
2 , rgba = require('./rgba');
3
4/**
5 * Return the alpha component of the given `color`,
6 * or set the alpha component to the optional second `value` argument.
7 *
8 * Examples:
9 *
10 * alpha(#fff)
11 * // => 1
12 *
13 * alpha(rgba(0,0,0,0.3))
14 * // => 0.3
15 *
16 * alpha(#fff, 0.5)
17 * // => rgba(255,255,255,0.5)
18 *
19 * @param {RGBA|HSLA} color
20 * @param {Unit} [value]
21 * @return {Unit|RGBA}
22 * @api public
23 */
24
25function alpha(color, value){
26 color = color.rgba;
27 if (value) {
28 return rgba(
29 new nodes.Unit(color.r),
30 new nodes.Unit(color.g),
31 new nodes.Unit(color.b),
32 value
33 );
34 }
35 return new nodes.Unit(color.a, '');
36};
37alpha.params = ['color', 'value'];
38module.exports = alpha;
Note: See TracBrowser for help on using the repository browser.