ce4c83ff
wxy
初始提交
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
var nodes = require('../nodes')
, hsla = require('./hsla')
, component = require('./component');
/**
* Return the hue component of the given `color`,
* or set the hue component to the optional second `value` argument.
*
* Examples:
*
* hue(#00c)
* // => 240deg
*
* hue(#00c, 90deg)
* // => #6c0
*
* @param {RGBA|HSLA} color
* @param {Unit} [value]
* @return {Unit|RGBA}
* @api public
*/
module.exports = function hue(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
value,
new nodes.Unit(hslaColor.s),
new nodes.Unit(hslaColor.l),
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('hue'));
};
|