Here you can find the source of interpolate(Color a, Color b, float f)
public static Color interpolate(Color a, Color b, float f)
//package com.java2s; /*/*from ww w .java 2 s . co m*/ Copyright 2012 James Edwards This file is part of Jhrome. Jhrome is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Jhrome is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Jhrome. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.Color; public class Main { public static Color interpolate(Color a, Color b, float f) { float rf = 1 - f; int red = (int) (a.getRed() * rf + b.getRed() * f); int green = (int) (a.getGreen() * rf + b.getGreen() * f); int blue = (int) (a.getBlue() * rf + b.getBlue() * f); int alpha = (int) (a.getAlpha() * rf + b.getAlpha() * f); return new Color(red, green, blue, alpha); } }