Here you can find the source of blend(Color c1, Color c2)
Parameter | Description |
---|---|
c1 | first color |
c2 | second color |
public static Color blend(Color c1, Color c2)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.awt.Color; public class Main { /** Blend 2 colors equally. @param c1 first color//from ww w . j a v a 2 s. co m @param c2 second color @return a new Color which is c1 and c2 blended in equal amounts */ public static Color blend(Color c1, Color c2) { return new Color((c1.getRed() + c2.getRed()) / 2, (c1.getGreen() + c2.getGreen()) / 2, (c1.getBlue() + c2.getBlue()) / 2); } /** Blend 2 colors in unequal amounts. The fractions f1, f2 indicate how much of each color to use; it's assumed that f1+f2=1.0 (or to within Java's tolerance). <p>For example, the call blend(Color.red, 0.1f, Color.white, 0.9f) returns a new Color which is 10% red and 90% white.</p> @param c1 first color @param f1 fraction of first color to use @param c2 second color @param f2 fraction of second color to use @return a new Color which is c1 and c2 blended in unequal amounts */ public static Color blend(Color c1, float f1, Color c2, float f2) { return new Color((int) (f1 * c1.getRed() + f2 * c2.getRed()), (int) (f1 * c1.getGreen() + f2 * c2.getGreen()), (int) (f1 * c1.getBlue() + f2 * c2.getBlue())); } }