Creates a new ColorList by blending all colors in the list with each
other (successive indices only)
@param amount
blend amount
@return new color list
348203
function(amount){
		var clrs = [],
			len = this.colors.length;
		for(var i=0; i< len; i++){
			var index = i > 0 ? i -1 : clrs.length - 1,
				c = this.colors[index];
			clrs.push(this.colors[i].getBlended(c,amount));
		}
		return new ColorList(clrs);
	}
684504
public static Color randomColor(Random random) {
		if (null == random) {
			random = RandomUtil.getRandom();
		}
		return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
	}
807602
public void mutate(float amount) {
		for (int i = 0; i < numKnots; i++) {
			int rgb = yKnots[i];
			int r = ((rgb >> 16) & 0xff);
			int g = ((rgb >> 8) & 0xff);
			int b = (rgb & 0xff);
			r = PixelUtils.clamp( (int)(r + amount * 255 * (Math.random()-0.5)) );
			g = PixelUtils.clamp( (int)(g + amount * 255 * (Math.random()-0.5)) );
			b = PixelUtils.clamp( (int)(b + amount * 255 * (Math.random()-0.5)) );
			yKnots[i] = 0xff000000 | (r << 16) | (g << 8) | b;
			knotTypes[i] = RGB|SPLINE;
		}
		sortKnots();
		rebuildGradient();
	}
1159625
function(args) {

                var amount = Number.isFinite(args.amount) ? args.amount : 1;

                return joint.util.template('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({
                    a: 0.2126 + 0.7874 * (1 - amount),
                    b: 0.7152 - 0.7152 * (1 - amount),
                    c: 0.0722 - 0.0722 * (1 - amount),
                    d: 0.2126 - 0.2126 * (1 - amount),
                    e: 0.7152 + 0.2848 * (1 - amount),
                    f: 0.0722 - 0.0722 * (1 - amount),
                    g: 0.2126 - 0.2126 * (1 - amount),
                    h: 0.0722 + 0.9278 * (1 - amount)
                });
            }
52398
function(color1, color2, amount) {
    var p = amount / 100.0;
    var w = p * 2 - 1;
    var hsl1 = this.toHSL(color1);
    var hsl2 = this.toHSL(color2);
    var a = hsl1.a - hsl2.a;

    var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
    var w2 = 1 - w1;

    var rgb = [
        color1[0] * w1 + color2[0] * w2,
        color1[1] * w1 + color2[1] * w2,
        color1[2] * w1 + color2[2] * w2
    ];

    var alpha = color1[3] * p + color2[3] * (1 - p);
    rgb[3] = alpha;
    return rgb;
  }
260595
public void jmolColorByChain(){
		String script =
				"function color_by_chain(objtype, color_list) {"+ String.format("%n") +
				""+ String.format("%n") +
				"		 if (color_list) {"+ String.format("%n") +
				"		   if (color_list.type == \"string\") {"+ String.format("%n") +
				"		     color_list = color_list.split(\",\").trim();"+ String.format("%n") +
				"		   }"+ String.format("%n") +
				"		 } else {"+ String.format("%n") +
				"		   color_list = [\"104BA9\",\"AA00A2\",\"C9F600\",\"FFA200\",\"284A7E\",\"7F207B\",\"9FB82E\",\"BF8B30\",\"052D6E\",\"6E0069\",\"83A000\",\"A66A00\",\"447BD4\",\"D435CD\",\"D8FA3F\",\"FFBA40\",\"6A93D4\",\"D460CF\",\"E1FA71\",\"FFCC73\"];"+ String.format("%n") +
				"		 }"+ String.format("%n") +

				"		 var cmd2 = \"\";"+ String.format("%n") +

				"		 if (!objtype) {"+ String.format("%n") +
				"		   var type_list  = [ \"backbone\",\"cartoon\",\"dots\",\"halo\",\"label\",\"meshribbon\",\"polyhedra\",\"rocket\",\"star\",\"strand\",\"strut\",\"trace\"];"+ String.format("%n") +
				"		   cmd2 = \"color \" + type_list.join(\" none; color \") + \" none;\";"+ String.format("%n") +
				"		   objtype = \"atoms\";"+ String.format("%n") +

				"		 }"+ String.format("%n") +

				"		 var chain_list  = script(\"show chain\").trim().lines;"+ String.format("%n") +
				"		 var chain_count = chain_list.length;"+ String.format("%n") +

				"		 var color_count = color_list.length;"+ String.format("%n") +
				"		 var sel = {selected};"+ String.format("%n") +
				"		 var cmds = \"\";"+ String.format("%n") +


				"		 for (var chain_number=1; chain_number<=chain_count; chain_number++) {"+ String.format("%n") +
				"		   // remember, Jmol arrays start with 1, but % can return 0"+ String.format("%n") +
				"		   cmds += \"select sel and :\" + chain_list[chain_number] + \";color \" + objtype + \" [x\" + color_list[(chain_number-1) % color_count + 1] + \"];\" + cmd2;"+ String.format("%n") +
				"		 }"+ String.format("%n") +
				"		 script INLINE @{cmds + \"select sel\"}"+ String.format("%n") +
				"}";

		executeCmd(script);
	}
521634
public DataRange color(String... colors) {
        if (colors == null || colors.length == 0) {
            return this;
        }
        this.color().addAll(Arrays.asList(colors));
        return this;
    }
434182
def +(color2)
    Color.new(
      (self.red + color2.red) / 2.0,
      (self.green + color2.green) / 2.0,
      (self.blue + color2.blue) / 2.0
    )
  end
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);
  }
678258
public function blend(RGBColor $color, $amount)
    {
        return $this->setFromArray(array(
                    min(255, min($this->getRed(), $color->getRed()) + round(abs($color->getRed() - $this->getRed()) * $amount))
                    , min(255, min($this->getGreen(), $color->getGreen()) + round(abs($color->getGreen() - $this->getGreen()) * $amount))
                    , min(255, min($this->getBlue(), $color->getBlue()) + round(abs($color->getBlue() - $this->getBlue()) * $amount))
                    , min(100, min($this->getAlpha(), $color->getAlpha()) + round(abs($color->getAlpha() - $this->getAlpha()) * $amount))
        ));
    }
269570
def merge(args):
    
    p = OptionParser(merge.__doc__)
    p.add_option("--colorlist", default="black,red,pink,blue,green",
                 help="The color palette [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    colorlist = opts.colorlist.split(",")
    assert len(colorlist) >= len(args), "Need more colors in --colorlist"

    g = BiGraph()
    for a, c in zip(args, colorlist):
        g.read(a, color=c)

    g.draw("merged.png")
1222701
public static int alphaMixColors(int backgroundColor, int foregroundColor) {
		final byte ALPHA_CHANNEL = 24;
		final byte RED_CHANNEL = 16;
		final byte GREEN_CHANNEL = 8;
		final byte BLUE_CHANNEL = 0;

		final double ap1 = (double) (backgroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
		final double ap2 = (double) (foregroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
		final double ap = ap2 + (ap1 * (1 - ap2));

		final double amount1 = (ap1 * (1 - ap2)) / ap;
		final double amount2 = amount1 / ap;

		int a = ((int) (ap * 255d)) & 0xff;

		int r = ((int) (((float) (backgroundColor >> RED_CHANNEL & 0xff) * amount1) +
				((float) (foregroundColor >> RED_CHANNEL & 0xff) * amount2))) & 0xff;
		int g = ((int) (((float) (backgroundColor >> GREEN_CHANNEL & 0xff) * amount1) +
				((float) (foregroundColor >> GREEN_CHANNEL & 0xff) * amount2))) & 0xff;
		int b = ((int) (((float) (backgroundColor & 0xff) * amount1) +
				((float) (foregroundColor & 0xff) * amount2))) & 0xff;

		return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
	}
994934
function(list, map, legendSize) {
            var hexColor;
            this.colorList = [];
            this.hcConfig.colors = [];
            for(i = 0; i < list.length; i++) {
                hexColor = this.colorPalette.getColor(list[i], map[list[i]], legendSize);
                this.colorList.push(hexColor);
                this.hcConfig.colors.push(this.colorUtils.addAlphaToColor(hexColor, 1.0));
            }
        }
1311471
function Darken($amount)
    {
        $floatAmount = (float)$amount;
        if ($floatAmount < 0 || $floatAmount > 1) {
            throw new \InvalidArgumentException('Colors can be only lightened with amounts between 0 and 1');
        }
        $this->r = $this->DarkenColor($this->r, $floatAmount);
        $this->g = $this->DarkenColor($this->g, $floatAmount);
        $this->b = $this->DarkenColor($this->b, $floatAmount);
    }
134770
private function DarkenColor($color, $amount)
    {
        $newColor = $color * (1 - $amount);
        return min(max(round($newColor), 0x00), 0xff);
    }
1138247
function createColoredCanvas(color)
{
    const canvas = document.createElement('canvas');

    canvas.width = 6;
    canvas.height = 1;

    const context = canvas.getContext('2d');

    context.fillStyle = color;
    context.fillRect(0, 0, 6, 1);

    return canvas;
}
991967
@Override
	public Color[] generateColors(int numColors) {
		Color[] colors = new Color[numColors];
		// fix the seed to always get the same colors for the same numColors parameter and ranges for hue, saturation and brightness
		Random rand = new Random(0);
		for(int i = 0; i < numColors; ++i)
		{
			float hueRatio = i/(float)numColors;
			float saturationRatio = rand.nextFloat();
			float brightnessRatio = rand.nextFloat();
			float hue = lerp(hueMin, hueMax, hueRatio);
			float saturation = lerp(saturationMin, saturationMax, saturationRatio);
			float brightness = lerp(brightnessMin, brightnessMax, brightnessRatio);
			colors[i] = Color.getHSBColor(hue, saturation, brightness);
		}
		
		return colors;
	}