Maps a hue on the RGB color wheel to Itten's RYB wheel.

  Parameters:
    :hue:
      The hue on the RGB color wheel [0...360]

  Returns:
    An approximation of the corresponding hue on Itten's RYB wheel.

  >>> rgb_to_ryb(15)
  26.0
168778
def rgb_to_ryb(hue):
  
  d = hue % 15
  i = int(hue / 15)
  x0 = _RybWheel[i]
  x1 = _RybWheel[i+1]
  return x0 + (x1-x0) * d / 15
969908
def colors
      @colors ||= (0...(6 * 7)).map do |n|
        pi_3 = Math::PI / 3
        n *= 1.0 / 6
        r  = (3 * Math.sin(n           ) + 3).to_i
        g  = (3 * Math.sin(n + 2 * pi_3) + 3).to_i
        b  = (3 * Math.sin(n + 4 * pi_3) + 3).to_i
        36 * r + 6 * g + b + 16
      end
    end
645158
def name2rgb(hue):
    
    r, g, b = colorsys.hsv_to_rgb(hue / 360.0, .8, .7)
    return tuple(int(x * 256) for x in [r, g, b])
253583
def xterm_to_rgb(xcolor):
    
    assert 0 <= xcolor <= 255
    if xcolor < 16:
        # basic colors
        return BASIC16[xcolor]
    elif 16 <= xcolor <= 231:
        # color cube
        xcolor -= 16
        return (CUBE_STEPS[xcolor // 36 % 6],
                CUBE_STEPS[xcolor // 6 % 6],
                CUBE_STEPS[xcolor % 6])
    elif 232 <= xcolor <= 255:
        # gray tone
        c = 8 + (xcolor - 232) * 0x0A
        return (c, c, c)
390379
def _hex_to_rgb(color: str) -> Tuple[int, ...]:
        
        if color.startswith('#'):
            color = color.lstrip('#')
        return tuple(int(color[i:i + 2], 16) for i in (0, 2, 4))
74911
private static double hueToRGB(final double m1, final double m2, double h)
    {
        // see http://www.w3.org/TR/css3-color/
        //
        // HOW TO RETURN hue.to.rgb(m1, m2, h):
        // IF h<0: PUT h+1 IN h
        // IF h>1: PUT h-1 IN h
        // IF h*6<1: RETURN m1+(m2-m1)*h*6
        // IF h*2<1: RETURN m2
        // IF h*3<2: RETURN m1+(m2-m1)*(2/3-h)*6
        // RETURN m1

        if (h < 0)
        {
            h++;
        }
        if (h > 1)
        {
            h--;
        }
        if ((h * 6) < 1)
        {
            return m1 + ((m2 - m1) * h * 6);
        }
        if ((h * 2) < 1)
        {
            return m2;
        }
        if ((h * 3) < 2)
        {
            return m1 + ((m2 - m1) * ((2.0 / 3) - h) * 6);
        }
        return m1;
    }
592607
def hex_to_rgb(h):
    
    h = h.lstrip('#')
    return tuple(int(h[i:i+2], 16)/255. for i in (0, 2 ,4))
258787
private static final double[] getRGB(double hue, double saturation, double brightness) {
        double[] rgb = {0.0, 0.0, 0.0};

        double tmpHue = hue * 360.0;
        int hi;
        double f;
        double p, q, t;

        hi = (int)Math.floor(tmpHue / 60.0) % 6;
        f  = tmpHue / 60.0 - hi;
        p  = (brightness * (1.0 - saturation));
        q  = (brightness * (1.0 - saturation * f));
        t  = (brightness * (1.0 - saturation * (1.0 - f)));

        switch (hi) {
        case 0:
            rgb[0] = brightness;
            rgb[1] = t;
            rgb[2] = p;
            break;
        case 1:
            rgb[0] = q;
            rgb[1] = brightness;
            rgb[2] = p;
            break;
        case 2:
            rgb[0] = p;
            rgb[1] = brightness;
            rgb[2] = t;
            break;
        case 3:
            rgb[0] = p;
            rgb[1] = q;
            rgb[2] = brightness;
            break;
        case 4:
            rgb[0] = t;
            rgb[1] = p;
            rgb[2] = brightness;
            break;
        case 5:
            rgb[0] = brightness;
            rgb[1] = p;
            rgb[2] = q;
            break;
        default:
            break;
        }

        return rgb;
    }
87472
def hex_to_rgb(self, h):
        """"""
        rgb = (self.hex_to_red(h), self.hex_to_green(h), self.hex_to_blue(h))
        return rgb
704246
function spin(color, amount) {
    var hsl = tinycolor(color).toHsl();
    var hue = (hsl.h + amount) % 360;
    hsl.h = hue < 0 ? 360 + hue : hue;
    return tinycolor(hsl);
}
554948
private void RGBtoHSV(float red, float green, float blue) {

        float min = 0;
        float max = 0;
        float delta = 0;

        min = MIN(red, green, blue);
        max = MAX(red, green, blue);

        m_bri = max; // v

        delta = max - min;

        if (max != 0) {
            m_sat = delta / max; // s
        } else {
            m_sat = 0;
            m_hue = 0;
            return;
        }

        if (delta == 0) {
            m_hue = 0;
            return;
        }

        if (red == max) {
            m_hue = (green - blue) / delta;
        } else if (green == max) {
            m_hue = 2 + ((blue - red) / delta);
        } else {
            m_hue = 4 + ((red - green) / delta);
        }

        m_hue *= 60;

        if (m_hue < 0) {
            m_hue += 360;
        }
    }
280757
def create_thread_color_cycle():
    
    if not color_available:
        return itertools.cycle([None])

    return itertools.cycle(
        (
            colorama.Fore.CYAN,
            colorama.Fore.BLUE,
            colorama.Fore.MAGENTA,
            colorama.Fore.GREEN,
        )
    )
701039
def RGB_to_HSL(cobj, *args, **kwargs):
    
    var_R = cobj.rgb_r
    var_G = cobj.rgb_g
    var_B = cobj.rgb_b

    var_max = max(var_R, var_G, var_B)
    var_min = min(var_R, var_G, var_B)

    var_H = __RGB_to_Hue(var_R, var_G, var_B, var_min, var_max)
    var_L = 0.5 * (var_max + var_min)

    if var_max == var_min:
        var_S = 0
    elif var_L <= 0.5:
        var_S = (var_max - var_min) / (2.0 * var_L)
    else:
        var_S = (var_max - var_min) / (2.0 - (2.0 * var_L))

    return HSLColor(
        var_H, var_S, var_L)
1708
def XYZ_to_RGB(cobj, target_rgb, *args, **kwargs):
    
    temp_X = cobj.xyz_x
    temp_Y = cobj.xyz_y
    temp_Z = cobj.xyz_z

    logger.debug("  \- Target RGB space: %s", target_rgb)
    target_illum = target_rgb.native_illuminant
    logger.debug("  \- Target native illuminant: %s", target_illum)
    logger.debug("  \- XYZ color's illuminant: %s", cobj.illuminant)

    # If the XYZ values were taken with a different reference white than the
    # native reference white of the target RGB space, a transformation matrix
    # must be applied.
    if cobj.illuminant != target_illum:
        logger.debug("  \* Applying transformation from %s to %s ",
                     cobj.illuminant, target_illum)
        # Get the adjusted XYZ values, adapted for the target illuminant.
        temp_X, temp_Y, temp_Z = apply_chromatic_adaptation(
            temp_X, temp_Y, temp_Z,
            orig_illum=cobj.illuminant, targ_illum=target_illum)
        logger.debug("  \*   New values: %.3f, %.3f, %.3f",
                     temp_X, temp_Y, temp_Z)

    # Apply an RGB working space matrix to the XYZ values (matrix mul).
    rgb_r, rgb_g, rgb_b = apply_RGB_matrix(
        temp_X, temp_Y, temp_Z,
        rgb_type=target_rgb, convtype="xyz_to_rgb")

    # v
    linear_channels = dict(r=rgb_r, g=rgb_g, b=rgb_b)
    # V
    nonlinear_channels = {}
    if target_rgb == sRGBColor:
        for channel in ['r', 'g', 'b']:
            v = linear_channels[channel]
            if v <= 0.0031308:
                nonlinear_channels[channel] = v * 12.92
            else:
                nonlinear_channels[channel] = 1.055 * math.pow(v, 1 / 2.4) - 0.055
    elif target_rgb == BT2020Color:
        if kwargs.get('is_12_bits_system'):
            a, b = 1.0993, 0.0181
        else:
            a, b = 1.099, 0.018
        for channel in ['r', 'g', 'b']:
            v = linear_channels[channel]
            if v < b:
                nonlinear_channels[channel] = v * 4.5
            else:
                nonlinear_channels[channel] = a * math.pow(v, 0.45) - (a - 1)
    else:
        # If it's not sRGB...
        for channel in ['r', 'g', 'b']:
            v = linear_channels[channel]
            nonlinear_channels[channel] = math.pow(v, 1 / target_rgb.rgb_gamma)

    return target_rgb(
        nonlinear_channels['r'], nonlinear_channels['g'], nonlinear_channels['b'])
1068598
def color_reducer(c1, c2):
    """"""
    return tuple(v1 + v2 for v1, v2 in itertools.izip(c1, c2))
621589
def _rgb2ycbcr(self, mode):
        """"""

        self._check_modes(("RGB", "RGBA"))

        (self.channels[0], self.channels[1], self.channels[2]) = \
            rgb2ycbcr(self.channels[0],
                      self.channels[1],
                      self.channels[2])

        if self.fill_value is not None:
            self.fill_value[0:3] = rgb2ycbcr(self.fill_value[0],
                                             self.fill_value[1],
                                             self.fill_value[2])

        self.mode = mode
1070893
def RGB_to_CMY(cobj, *args, **kwargs):
    
    cmy_c = 1.0 - cobj.rgb_r
    cmy_m = 1.0 - cobj.rgb_g
    cmy_y = 1.0 - cobj.rgb_b

    return CMYColor(cmy_c, cmy_m, cmy_y)