Two adjacent colors on 12-part color wheel
421695
function (color, angle) {
			var hsl, color0, color2;
			if (!angle) {
				angle = 30;
			}
			hsl = ColorHelper.rgbToHSL(color);
			hsl[0] = (hsl[0] + angle) % 360;
			color0 = ColorHelper.hslToHexColor(hsl);
			color0 = ColorHelper.darken(color0, 8);
			color0 = ColorHelper.saturate(color0, -6);
			hsl = ColorHelper.rgbToHSL(color);
			hsl[0] = (hsl[0] - angle + 360) % 360;
			color2 = ColorHelper.hslToHexColor(hsl);
			return [color0, color, color2];
		}
843609
function rgbaToHsla(h, s, l, a) {
  return [...rgbToHsl(h,s,l), a];
}
32215
private void HSVtoRGB(float hue, float sat, float bri) {

        int i;
        float f;
        float p;
        float q;
        float t;
        if (sat == 0) {
            m_red = bri;
            m_green = bri;
            m_blue = bri;
            return;
        }
        hue /= 60;
        i = (int)Math.floor(hue);
        f = hue - i;
        p = bri * (1 - sat);
        q = bri * (1 - (sat * f));
        t = bri * (1 - (sat * (1 - f)));
        switch (i) {
            case 0:
                m_red = bri;
                m_green = t;
                m_blue = p;
                break;
            case 1:
                m_red = q;
                m_green = bri;
                m_blue = p;
                break;
            case 2:
                m_red = p;
                m_green = bri;
                m_blue = t;
                break;
            case 3:
                m_red = p;
                m_green = q;
                m_blue = bri;
                break;
            case 4:
                m_red = t;
                m_green = p;
                m_blue = bri;
                break;
            default: // case 5:
                m_red = bri;
                m_green = p;
                m_blue = q;
                break;
        }
    }
67753
function colorwheel(pos) {
  pos = 255 - pos;
  if (pos < 85) { return rgb2Int(255 - pos * 3, 0, pos * 3); }
  else if (pos < 170) { pos -= 85; return rgb2Int(0, pos * 3, 255 - pos * 3); }
  else { pos -= 170; return rgb2Int(pos * 3, 255 - pos * 3, 0); }
}
64370
private static int blendColors(int color1, int color2, float ratio) {
    final float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
  }
644227
def ggplot_color_wheel(n, start = 15, saturation_adjustment = None, saturation = 0.65, lightness = 1.0, prefix = ''):
    '''
    '''
    hues = range(start, start + 360, 360/n)
    rgbcolors = ['%.2x%.2x%.2x' % (255 * hlscol[0], 255 * hlscol[1], 255 * hlscol[2]) for hlscol in [colorsys.hls_to_rgb(float(h % 360) / 360.0, saturation, lightness) for h in hues]]
    if saturation_adjustment:
        return [saturate_hex_color(prefix + rgbcol, saturation_adjustment) for rgbcol in rgbcolors]
    else:
        return rgbcolors
686634
def setPixelColorRGB(self, n, red, green, blue):
        
        self.setPixelColor(n, Color(red, green, blue))
1032232
function Color4(r, g, b, a) {
            if (r === void 0) { r = 0; }
            if (g === void 0) { g = 0; }
            if (b === void 0) { b = 0; }
            if (a === void 0) { a = 1; }
            this.r = r;
            this.g = g;
            this.b = b;
            this.a = a;
        }
950604
def rgb2rgba(rgb):
    """"""
    rgba = []
    for i in range(0, len(rgb), 3):
        rgba += rgb[i:i+3]
        rgba.append(255)

    return rgba
701215
def get_vertex_surrounding_multicolor(graph, vertex):
    
    result = Multicolor()
    for edge in graph.get_edges_by_vertex(vertex):
        result += edge.multicolor
    return result
1121492
def _make_A_and_part_of_b_adjacent(self, ref_crds):
        
        rot = self._rotate_rows(ref_crds)
        A = 2*(rot - ref_crds)
        partial_b = (rot**2 - ref_crds**2).sum(1)
        return A, partial_b
758395
function(color1, color2) {
		var result = color1.slice();
		for (var i=0;i<3;i++) {
			for (var j=1;j<arguments.length;j++) {
				result[i] += arguments[j][i];
			}
		}
		return result;
	}
1350901
def _mix(color1, color2, weight=0.5, **kwargs):
    
    weight = float(weight)
    c1 = color1.value
    c2 = color2.value
    p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight
    w = p * 2 - 1
    a = c1[3] - c2[3]

    w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)) + 1) / 2.0
    w2 = 1 - w1
    q = [w1, w1, w1, p]
    r = [w2, w2, w2, 1 - p]
    return ColorValue([c1[i] * q[i] + c2[i] * r[i] for i in range(4)])
1272390
function color2hex6(color) {
	const named = namedColors[color.toLowerCase()]; if (named) { return '#'+ named; }
	const hex = (/^#([0-9A-Fa-f]{3,8})$/).exec(color); if (hex) {
		const c = hex[1]; if (c.length !== 5 && c.length !== 7) {
			return '#'+ (c.length < 6 ? c.split('').map(x => x+x).join('') : c).slice(0, 6);
		}
	}
	const rgb = (/^rgba?[(]([\d.e%+-]+)\s*(?:\s|,\s*)([\d.e%+-]+)\s*(?:\s|,\s*)([\d.e%+-]+)\s*(?:\s|,\s*)?.*?[)]$/).exec(color); if (rgb) {
		const r = parseNumber(rgb[1], 255), g = parseNumber(rgb[2], 255), b = parseNumber(rgb[3], 255);
		if (isFinite(r) && isFinite(g) && isFinite(b)) { return hexOf(r, g, b); }
	}
	const hsl = (/^hsla?[(]([\d.e+-]+)(|deg|rad|grad|turn)\s*(?:\s|,\s*)([\d.e+-]+[%])\s*(?:\s|,\s*)([\d.e+-]+[%])\s*(?:\s|,\s*)?.*?[)]$/).exec(color); if (hsl) {
		const h = parseNumber(hsl[1]) * hueMultiplier[hsl[2]], s = parseNumber(hsl[3], 100), l = parseNumber(hsl[4], 100);
		if (isFinite(h) && isFinite(s) && isFinite(l)) {
			const { r, g, b, } = hsl2rgb((h % 1 + 1) % 1, s < 0 ? 0 : s > 1 ? 1 : s, l < 0 ? 0 : l > 1 ? 1 : l);
			return hexOf(r, g, b);
		}
	}
	return null; // whatever
	function hexOf(r, g, b) {
		function clamp(n) { return (n < 0 ? 0 : n > 255 ? 255 : n |0).toString(16).padStart(2, '0'); }
		return '#'+ clamp(r) + clamp(g) + clamp(b);
	}
	function parseNumber(n, base) { return n[n.length - 1] === '%' ? n.slice(0, -1) / base : +n; }
	function hsl2rgb(h, s, l) { // basically from here: https://stackoverflow.com/a/9493060
		if (s === 0) { return { r: l * 256, g: l * 256, b: l * 256, }; } // achromatic
		const q = l < 0.5 ? l * (1 + s) : l + s - l * s, p = 2 * l - q;
		return {
			r: hue2rgb(p, q, h + 1/3) * 256,
			g: hue2rgb(p, q, h) * 256,
			b: hue2rgb(p, q, h - 1/3) * 256,
		};
		function hue2rgb(p, q, t) {
			if (t < 0) { t += 1; } if (t > 1) { t -= 1; }
			if (t < 1/6) { return p + (q - p) * 6 * t; }
			if (t < 1/2) { return q; }
			if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
			return p;
		}
	}
}
1068598
def color_reducer(c1, c2):
    """"""
    return tuple(v1 + v2 for v1, v2 in itertools.izip(c1, c2))
1032890
function(color) {
		var l = color[2];

		if (color[1] == 0) {
			l = Math.round(l*255);
			return [l, l, l];
		} else {
			function hue2rgb(p, q, t) {
				if (t < 0) t += 1;
				if (t > 1) t -= 1;
				if (t < 1/6) return p + (q - p) * 6 * t;
				if (t < 1/2) return q;
				if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
				return p;
			}

			var s = color[1];
			var q = (l < 0.5 ? l * (1 + s) : l + s - l * s);
			var p = 2 * l - q;
			var r = hue2rgb(p, q, color[0] + 1/3);
			var g = hue2rgb(p, q, color[0]);
			var b = hue2rgb(p, q, color[0] - 1/3);
			return [Math.round(r*255), Math.round(g*255), Math.round(b*255)];
		}
	}
339710
function(color1, color2) {
		for (var i=0;i<3;i++) {
			for (var j=1;j<arguments.length;j++) {
				color1[i] *= arguments[j][i] / 255;
			}
			color1[i] = Math.round(color1[i]);
		}
		return color1;
	}