Here you can find the source of mix(Color c1, Color c2, double f)
public static Color mix(Color c1, Color c2, double f)
//package com.java2s; /*/*www . j a va2 s. c om*/ * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ import java.awt.*; public class Main { /** * Mix two colors by a given amount */ public static Color mix(Color c1, Color c2, double f) { if (f >= 1.0) return c2; if (f <= 0) return c1; double r1 = c1.getRed(); double g1 = c1.getGreen(); double b1 = c1.getBlue(); double r2 = c2.getRed(); double g2 = c2.getGreen(); double b2 = c2.getBlue(); double r = f * r2 + (1 - f) * r1; double g = f * g2 + (1 - f) * g1; double b = f * b2 + (1 - f) * b1; Color c3 = new Color(Math.min((int) (r), 255), Math.min((int) (g), 255), Math.min((int) (b), 255)); return c3; } }