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