Here you can find the source of interpolate(double factor, Color bottomCol, Color topCol)
public static String interpolate(double factor, Color bottomCol, Color topCol)
//package com.java2s; import java.awt.Color; public class Main { public static String interpolate(double factor, Color bottomCol, Color topCol) { int red, blue, green; red = (int) Math.round((1.0 - factor) * bottomCol.getRed() + factor * topCol.getRed()); blue = (int) Math.round((1.0 - factor) * bottomCol.getBlue() + factor * topCol.getBlue()); green = (int) Math.round((1.0 - factor) * bottomCol.getGreen() + factor * topCol.getGreen()); Color color = new Color(Math.min(red, 255), Math.min(green, 255), Math.min(blue, 255)); return Integer.toHexString(color.getRGB()).substring(2, 8); }//from w w w . j av a2 s.c o m }