Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
685 bytes
|
Line | |
---|
1 | var nodes = require('../nodes')
|
---|
2 | , rgba = require('./rgba');
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * Return the green component of the given `color`,
|
---|
6 | * or set the green component to the optional second `value` argument.
|
---|
7 | *
|
---|
8 | * Examples:
|
---|
9 | *
|
---|
10 | * green(#0c0)
|
---|
11 | * // => 204
|
---|
12 | *
|
---|
13 | * green(#000, 255)
|
---|
14 | * // => #0f0
|
---|
15 | *
|
---|
16 | * @param {RGBA|HSLA} color
|
---|
17 | * @param {Unit} [value]
|
---|
18 | * @return {Unit|RGBA}
|
---|
19 | * @api public
|
---|
20 | */
|
---|
21 |
|
---|
22 | function green(color, value){
|
---|
23 | color = color.rgba;
|
---|
24 | if (value) {
|
---|
25 | return rgba(
|
---|
26 | new nodes.Unit(color.r),
|
---|
27 | value,
|
---|
28 | new nodes.Unit(color.b),
|
---|
29 | new nodes.Unit(color.a)
|
---|
30 | );
|
---|
31 | }
|
---|
32 | return new nodes.Unit(color.g, '');
|
---|
33 | };
|
---|
34 | green.params = ['color', 'value'];
|
---|
35 | module.exports = green;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.