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:
801 bytes
|
Line | |
---|
1 | var nodes = require('../nodes')
|
---|
2 | , hsla = require('./hsla')
|
---|
3 | , component = require('./component');
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Return the saturation component of the given `color`,
|
---|
7 | * or set the saturation component to the optional second `value` argument.
|
---|
8 | *
|
---|
9 | * Examples:
|
---|
10 | *
|
---|
11 | * saturation(#00c)
|
---|
12 | * // => 100%
|
---|
13 | *
|
---|
14 | * saturation(#00c, 50%)
|
---|
15 | * // => #339
|
---|
16 | *
|
---|
17 | * @param {RGBA|HSLA} color
|
---|
18 | * @param {Unit} [value]
|
---|
19 | * @return {Unit|RGBA}
|
---|
20 | * @api public
|
---|
21 | */
|
---|
22 |
|
---|
23 | function saturation(color, value){
|
---|
24 | if (value) {
|
---|
25 | var hslaColor = color.hsla;
|
---|
26 | return hsla(
|
---|
27 | new nodes.Unit(hslaColor.h),
|
---|
28 | value,
|
---|
29 | new nodes.Unit(hslaColor.l),
|
---|
30 | new nodes.Unit(hslaColor.a)
|
---|
31 | )
|
---|
32 | }
|
---|
33 | return component(color, new nodes.String('saturation'));
|
---|
34 | }
|
---|
35 | saturation.params = ['color', 'value'];
|
---|
36 | module.exports = saturation;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.