Calculates the colors of the rainbow

 @return [Array]
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
66080
def get_color_between(color1, color2, i):
    
    if i <= 0:
        return color1
    if i >= 1:
        return color2
    return (int(color1[0] + (color2[0] - color1[0]) * i),
            int(color1[1] + (color2[1] - color1[1]) * i),
            int(color1[2] + (color2[2] - color1[2]) * i))
869549
def _get_color(self, r, g, b):
        
        clr = (r, g, b)
        return clr
7345
function(color1, color2) {
		for (var i=0;i<3;i++) {
			for (var j=1;j<arguments.length;j++) {
				color1[i] += arguments[j][i];
			}
		}
		return color1;
	}
646077
def rainbow(n=1000, saturation=1, value=1):
    
    for i in range(n):
        hue = i / float(n)
        color = [int(x * 255) for x in colorsys.hsv_to_rgb(hue, saturation, value)]
        yield ("#%02x%02x%02x" % tuple(color)).upper()
113535
private function calcHSL()
    {
        // RGB -> HSL
        self::rgb2hsl($this->r, $this->g, $this->b, $h, $s, $l);

        return [$h, $s, $l];
    }
276938
def color_array_by_hue_mix(value, palette):
    
    if int(value, 2) > 0:

        # Convert bits to list and reverse order to avoid issues with
        # differing lengths
        int_list = [int(i) for i in list(value[2:])]
        int_list.reverse()

        # since this is a 1D array, we need the zeroth elements
        # of np.nonzero.
        locs = np.nonzero(int_list)[0]
        # print(locs)
        # print(palette)
        rgb_vals = [palette[i] for i in locs]

        rgb = [0]*len(rgb_vals[0])  # We don't know if it's rgb or rgba
        for val in rgb_vals:
            for index in range(len(val)):
                rgb[index] += val[index]

        for i in range(len(rgb)):
            rgb[i] /= len(locs)

        return tuple(rgb)

    if int(value, 2) == 0:
        return (1, 1, 1) if len(palette[0]) == 3 else (1, 1, 1, 1)

    return -1
868115
def get_color_indices(color)   # :nodoc:
    invalid = 0x7FFF   # return from Colors#get_color when color is invalid

    index = Colors.new.get_color(color)
    index = invalid if color.respond_to?(:coerce) && (color < 8 || color > 63)
    if index == invalid
      [nil, nil]
    else
      [index, get_color_rbg(index)]
    end
  end
1274337
def rgb_to_hsl(red, green, blue)
      red = round_rgb_color(red)
      green = round_rgb_color(green)
      blue = round_rgb_color(blue)

      color_max = [red, green, blue].max
      color_min = [red, green, blue].min
      color_range = color_max - color_min
      if color_range == 0
        return [0, 0, (color_max * 100.0 / 255).to_i]
      end
      color_range = color_range.to_f
      hue = (case color_max
             when red then
               HUE_PER_6 * ((green - blue) / color_range)
             when green  then
               HUE_PER_6 * ((blue - red) / color_range) + HUE_PER_6 * 2
             else
               HUE_PER_6 * ((red - green) / color_range) + HUE_PER_6 * 4
             end)

      cnt = color_range / 2.0
      if cnt <= 127
        saturation = color_range / (color_max + color_min) * 100
      else
        saturation = color_range / (510 - color_max - color_min) * 100
      end
      lightness = (color_max + color_min) / 2.0 / 255.0 * 100

      [hue.round, saturation.round, lightness.round]
    end
890652
def rgb_to_xyz(colour)
      r, g, b = colour.map do |v|
          v /= 255.0
          if v > 0.04045
              v = ((v + 0.055 ) / 1.055)**2.4
          else
              v = v / 12.92
          end
          v *= 100
      end

      #Observer = 2°, Illuminant = D65
      x = r * 0.4124 + g * 0.3576 + b * 0.1805
      y = r * 0.2126 + g * 0.7152 + b * 0.0722
      z = r * 0.0193 + g * 0.1192 + b * 0.9505

      return [x, y, z]
    end
823451
def calculate_colorbar(self):
        
        self._base._process_values()
        self._base._find_range()
        X, Y = self._base._mesh()
        C = self._base._values[:, np.newaxis]
        return X, Y, C
477649
function initColors() {
	var low, high,
	    result = new Uint8Array( 0x1000000 );

	for ( low = 0; low < 0x100; low++ ) {
		for ( high = 0; high < 0x100; high++ ) {
			addTile( low, high );
		}
	}

	return result;

	function addTile( low, high ) {
		var colorLow, colorHigh, color,
		    offset = ( low << 16 ) | ( high << 8 );

		for ( var i = 0; i < 8; i++ ) {
			colorLow = ( low & 1 );
	    	colorHigh = ( high & 1 ) << 1;
	    	color = ( colorHigh | colorLow );

			result[ offset + i ] = color;

			low >>= 1;
	    	high >>= 1;
		}
	}
}
1318642
function(color, diff) {
		if (!(diff instanceof Array)) { diff = ROT.RNG.getNormal(0, diff); }
		var result = color.slice();
		for (var i=0;i<3;i++) {
			result[i] += (diff instanceof Array ? Math.round(ROT.RNG.getNormal(0, diff[i])) : diff);
		}
		return result;
	}
1332352
def rgba_floats_tuple(self, x):
        
        if x <= self.index[0]:
            return self.colors[0]
        if x >= self.index[-1]:
            return self.colors[-1]

        i = len([u for u in self.index if u < x])  # 0 < i < n.
        return tuple(self.colors[i-1])
669445
public Set<RGBColor> colours() {
        return stream().map(Pixel::toColor).collect(Collectors.toSet());
    }
433430
def _rgb_to_rgbw(color):
        
        # Get the maximum between R, G, and B
        max_value = max(color)

        # If the maximum value is 0, immediately return pure black.
        if max_value == 0:
            return [0] * 4

        # Figure out what the color with 100% hue is
        multiplier = 255 / max_value
        hue_red = color.R * multiplier
        hue_green = color.G * multiplier
        hue_blue = color.B * multiplier

        # Calculate the whiteness (not strictly speaking luminance)
        max_hue = max(hue_red, hue_green, hue_blue)
        min_hue = min(hue_red, hue_green, hue_blue)
        luminance = ((max_hue + min_hue) / 2 - 127.5) * 2 / multiplier

        # Calculate the output values
        r = max(0, min(255, int(color.R - luminance)))
        g = max(0, min(255, int(color.G - luminance)))
        b = max(0, min(255, int(color.B - luminance)))
        w = max(0, min(255, int(luminance)))

        return [r, g, b, w]
985093
def colors=(c)
      @colors = c.is_a?(ColorPair) ? c : ColorPair.for(c).first
      @win.bkgd(Ncurses.COLOR_PAIR(@colors.id)) unless @win.nil?

      component.colors = @colors if component?

      children.each { |ch|
        ch.colors = c
      }
    end