Java Utililty Methods Color Merge

List of utility methods to do Color Merge

Description

The list of methods to do Color Merge are organized into topic(s).

Method

ColormergeColor(Color a, Color b)
merge Color
return new Color((a.getRed() + b.getRed()) / 2, (a.getGreen() + b.getGreen()) / 2,
        (a.getBlue() + b.getBlue()) / 2,
        (a.getAlpha() + b.getAlpha()) / 2 + Math.abs(b.getAlpha() - a.getAlpha()));
ColormergeColor(Color c1, Color c2)
merges colors by maximum of components
float r, g, b;
r = Math.max(c1.getRed(), c2.getRed());
g = Math.max(c1.getGreen(), c2.getGreen());
b = Math.max(c1.getBlue(), c2.getBlue());
return new Color(r, g, b);
ColormergeColors(Color a, float fa, Color b, float fb)
Merges two colors.
if (a == null) {
    return b;
if (b == null) {
    return a;
return new Color((fa * a.getRed() + fb * b.getRed()) / (fa + fb) / 255f,
        (fa * a.getGreen() + fb * b.getGreen()) / (fa + fb) / 255f,
...
ColormergeColors(Color color1, Color color2)
merge Colors
return new Color((color1.getRed() + color2.getRed()) / 2, (color1.getGreen() + color2.getGreen()) / 2,
        (color1.getBlue() + color2.getBlue()) / 2);
ColormergeCols(Color col1, Color col2)
Merges two Color instances, to return a new Color with averaged values for red, green & blue.
int r = col1.getRed() + col2.getRed(), g = col1.getGreen() + col2.getGreen(),
        b = col1.getBlue() + col2.getBlue();
return new Color(r / 2, g / 2, b / 2);