Blame view

node_modules/stylus/lib/functions/rgb.js 716 Bytes
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
35
36
37
38
39
40
  var utils = require('../utils')
    , nodes = require('../nodes')
    , rgba = require('./rgba');
  
  /**
   * Return a `RGBA` from the r,g,b channels.
   *
   * Examples:
   *
   *    rgb(255,204,0)
   *    // => #ffcc00
   *
   *    rgb(#fff)
   *    // => #fff
   *
   * @param {Unit|RGBA|HSLA} red
   * @param {Unit} green
   * @param {Unit} blue
   * @return {RGBA}
   * @api public
   */
  
  module.exports = function rgb(red, green, blue){
    switch (arguments.length) {
      case 1:
        utils.assertColor(red);
        var color = red.rgba;
        return new nodes.RGBA(
            color.r
          , color.g
          , color.b
          , 1);
      default:
        return rgba(
            red
          , green
          , blue
          , new nodes.Unit(1));
    }
  };