Java Utililty Methods Color Blend

List of utility methods to do Color Blend

Description

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

Method

ColorblendColorKeepAlpha(Color source, Color dest)
blend Color Keep Alpha
return new Color(
        (int) (source.getRed() + (float) (dest.getRed() - source.getRed()) * (dest.getAlpha() / 255.0f)),
        (int) (source.getGreen()
                + (float) (dest.getGreen() - source.getGreen()) * (dest.getAlpha() / 255.0f)),
        (int) (source.getBlue() + (float) (dest.getBlue() - source.getBlue()) * (dest.getAlpha() / 255.0f)),
        source.getAlpha());
ColorblendColors(Color color, Color color1, double d)
blend Colors
if (color == null || color1 == null) {
    return null;
} else {
    int i = (int) ((double) color1.getRed() * d + (double) color.getRed() * (1.0D - d));
    int j = (int) ((double) color1.getGreen() * d + (double) color.getGreen() * (1.0D - d));
    int k = (int) ((double) color1.getBlue() * d + (double) color.getBlue() * (1.0D - d));
    int l = color.getAlpha();
    return new Color(i, j, k, l);
...
ColorblendColors(Color from, Color to, double toFraction)
blend Colors
toFraction = Math.min(1.0, toFraction);
double fromFraction = 1 - toFraction;
return new Color((int) (from.getRed() * fromFraction + to.getRed() * toFraction),
        (int) (from.getGreen() * fromFraction + to.getGreen() * toFraction),
        (int) (from.getBlue() * fromFraction + to.getBlue() * toFraction));
ColorblendColorsUnsafe(final float[] fractions, final Color[] colors, final float progress)
Unchecked version of #blendColors(float[],Color[],float)
final Color color;
final int[] indicies = getFractionIndicies(fractions, progress);
final float[] range = new float[] { fractions[indicies[0]], fractions[indicies[1]] };
final Color[] colorRange = new Color[] { colors[indicies[0]], colors[indicies[1]] };
final float max = range[1] - range[0];
final float value = progress - range[0];
final float weight = value / max;
color = blend(colorRange[0], colorRange[1], 1f - weight);
...