source: trip-planner-front/node_modules/stylus/lib/functions/red.js@ 6a3a178

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

initial commit

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