Blends the two supplied colors.

@return a color halfway between the two colors.
493473
public static final Color blend (Color c1, Color c2)
    {
        return new Color((c1.getRed() + c2.getRed()) >> 1,
                         (c1.getGreen() + c2.getGreen()) >> 1,
                         (c1.getBlue() + c2.getBlue()) >> 1);
    }
788616
protected Paint createVerticalGradient(Shape s, TwoColors colors) {
        Rectangle2D bounds  = s.getBounds2D();
        float       xCenter = (float) bounds.getCenterX();
        float       yMin    = (float) bounds.getMinY();
        float       yMax    = (float) bounds.getMaxY();

        return createGradient(xCenter, yMin, xCenter, yMax, new float[] { 0f, 1f }, new Color[] { colors.top, colors.bottom });
    }
151337
public Color multiply(Color c) {
		return new Color(r * c.r, g * c.g, b * c.b, a * c.a);
	}
325030
public Color darker(float scale) {
        scale = 1 - scale;
		Color temp = new Color(r * scale,g * scale,b * scale,a);
		
		return temp;
	}
721248
public static Color[] getNColors(int n) {
    Color[] colors = new Color[n];
    if (n <= basicColors.length) {
      System.arraycopy(basicColors, 0, colors, 0, n);
    } else {
      int s = 255 / (int)Math.ceil(Math.pow(n, (1.0 / 3.0)));
      int index = 0;
      OUTER: for (int i = 0; i < 256; i += s) {
        for (int j = 0; j < 256; j += s) {
          for (int k = 0; k < 256; k += s) {
            colors[index++] = new Color(i,j,k);
            if (index == n) { break OUTER; }
          }
        }
      }
    }
    return colors;
  }
366304
private Color getCellColour(double data, double min, double max) {
    double range = max - min;
    double position = data - min;

    // What proportion of the way through the possible values is that.
    double percentPosition = position / range;

    // Which colour group does that put us in.
    // int colourPosition = getColourPosition(percentPosition);

    int r = (int) (255 * red(percentPosition * 2 - 1));
    int g = (int) (255 * green(percentPosition * 2 - 1));
    int b = (int) (255 * blue(percentPosition * 2 - 1));

    // int r = lowValueColour.getRed();
    // int g = lowValueColour.getGreen();
    // int b = lowValueColour.getBlue();
    //
    // // Make n shifts of the colour, where n is the colourPosition.
    // for (int i = 0; i < colourPosition; i++) {
    // int rDistance = r - highValueColour.getRed();
    // int gDistance = g - highValueColour.getGreen();
    // int bDistance = b - highValueColour.getBlue();
    //
    // if ((Math.abs(rDistance) >= Math.abs(gDistance))
    // && (Math.abs(rDistance) >= Math.abs(bDistance))) {
    // // Red must be the largest.
    // r = changeColourValue(r, rDistance);
    // }
    // else if (Math.abs(gDistance) >= Math.abs(bDistance)) {
    // // Green must be the largest.
    // g = changeColourValue(g, gDistance);
    // }
    // else {
    // // Blue must be the largest.
    // b = changeColourValue(b, bDistance);
    // }
    // }

    return new Color(r, g, 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;
	}
947878
private Color variate(Color color) {
		assert color != null;
		final int diff = 30;
		// darken the color for value of diff
		int newRed = shiftColorPart(color.getRed() - diff);
		int newGreen = shiftColorPart(color.getGreen() - diff);
		int newBlue = shiftColorPart(color.getBlue() - diff);
		Color newColor = new Color(newRed, newGreen, newBlue);
		// start at the original section color again if darkening accidentally
		// resulted in black, which has already the meaning of section caves.
		if (newColor.equals(Color.black)) {
			newColor = colorMap.get(SECTION_START);
		}
		return newColor;
	}
876676
private static double colorBlending( double color1, double color2, int op ) {
        long argb1 = Double.doubleToRawLongBits( color1 );
        long r1 = ((argb1 >> 32) & 0xFFFF);
        long g1 = ((argb1 >> 16) & 0xFFFF);
        long b1 = ((argb1) & 0xFFFF);

        long argb2 = Double.doubleToRawLongBits( color2 );
        long r2 = ((argb2 >> 32) & 0xFFFF);
        long g2 = ((argb2 >> 16) & 0xFFFF);
        long b2 = ((argb2) & 0xFFFF);

        r1 = colorBlendingDigit( r1, r2, op );
        g1 = colorBlendingDigit( g1, g2, op );
        b1 = colorBlendingDigit( b1, b2, op );
        argb1 = r1 << 32 | g1 << 16 | b1;

        return Double.longBitsToDouble( argb1 );
    }
500229
@SuppressWarnings({ "checkstyle:magicnumber", "static-method" })
	@Pure
	public Color rgba(int color) {
		final int alpha = (color & 0xFF000000) >> 24;
		final int red = (color & 0x00FF0000) >> 16;
		final int green = (color & 0x0000FF00) >> 8;
		final int blue = color & 0x000000FF;
		final double opacity;
		switch (alpha) {
		case 0:
			opacity = 0.;
			break;
		case 255:
			opacity = 1.;
			break;
		default:
			opacity = ((double) alpha) / 255;
		}
		return Color.rgb(red, green, blue, opacity);
	}
709858
public static Color darker (Color color, double fraction)
	{
		int red   = (int) Math.round (color.getRed()   * (1.0 - fraction));
		int green = (int) Math.round (color.getGreen() * (1.0 - fraction));
		int blue  = (int) Math.round (color.getBlue()  * (1.0 - fraction));

		if (red   < 0) red   = 0; else if (red   > 255) red   = 255;
		if (green < 0) green = 0; else if (green > 255) green = 255;
		if (blue  < 0) blue  = 0; else if (blue  > 255) blue  = 255;

		int alpha = color.getAlpha();

		return new Color (red, green, blue, alpha);
	}
1107781
public static Style blue() {
        final Style style = new Style();
        style.color = PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_BLUE);
        return style;
    }
517424
function colorBlend(mode, color1, color2) {
    var ab = color1.alpha, cb, // backdrop
        as = color2.alpha, cs, // source
        ar, cr, r = [];        // result

    ar = as + ab * (1 - as);
    for (var i = 0; i < 3; i++) {
        cb = color1.rgb[i] / 255;
        cs = color2.rgb[i] / 255;
        cr = mode(cb, cs);
        if (ar) {
            cr = (as * cs + ab * (cb
                - as * (cb + cs - cr))) / ar;
        }
        r[i] = cr * 255;
    }

    return new(tree.Color)(r, ar);
}
815008
public Color getColorFor( double value ) {
        if (value <= min) {
            return colors[0];
        } else if (value >= max) {
            return colors[colors.length - 1];
        } else {
            for( int i = 1; i < colors.length; i++ ) {
                double v1 = values[i - 1];
                double v2 = values[i];
                if (value < v2) {

                    double v = (value - v1) / (v2 - v1);
                    Color interpolateColor = interpolateColor(colors[i - 1], colors[i], (float) v);
                    return interpolateColor;
                }
            }
            return colors[colors.length - 1];
        }
    }
620909
private function getMergedColorPart($type, $color1, $color2, $percentage)
    {
        return $color1->$type - ( ($percentage / 100) * ( $color1->$type - $color2->$type ) );
    }
862966
@Override
	public String colorBySubunit() {
		QuatSymmetrySubunits subunits = rotationAxisAligner.getSubunits();
		List<Integer> modelNumbers = subunits.getModelNumbers();
		List<String> chainIds = subunits.getChainIds();
		List<List<Integer>> orbits = rotationAxisAligner.getOrbits();
		int fold = rotationGroup.getRotation(0).getFold();

		Color[] col = null;
		Color4f[] colors = null;
		if (fold > 1) {
			col = ColorBrewer.Spectral.getColorPalette(2*fold);
			colors = ColorConverter.convertColor4f(col);
		} else {
			col = ColorBrewer.Spectral.getColorPalette(orbits.size());
			colors = ColorConverter.convertColor4f(col);
		}
		int half = colors.length/2;
		for (int i = 0; i < half; i++) {
			if (i % 2 != 0) {
			   Color4f temp = colors[i];
			   colors[i] = colors[half+i];
			   colors[half+i] = temp;
			}
		}
		Map<Color4f, List<String>> colorMap = new HashMap<Color4f, List<String>>();

		for (int i = 0; i < orbits.size(); i++) {
			for (int j = 0; j < fold; j++) {
				// assign alternating color sets to adjacent orbits
				int colorIndex = i;
				if (fold > 1) {
					if (i % 2 == 0) {
						colorIndex = j;
					} else {
						colorIndex = fold + j;
					}
				}
				int subunit = orbits.get(i).get(j);
				Color4f c = colors[colorIndex];
				List<String> ids = colorMap.get(c);
				if (ids == null) {
					ids = new ArrayList<String>();
					colorMap.put(c,  ids);
				}
				String id = getChainSpecification(modelNumbers, chainIds, subunit);
				ids.add(id);
			}
		}
		return defaultColoring + getJmolColorScript(colorMap) + getJmolLigandScript();
	}
61712
def blend(c1, c2):
    """"""
    return [c1[i] * (0xFF - c2[3]) + c2[i] * c2[3] >> 8 for i in range(3)]