Here you can find the source of interpolateColor(int rgba1, int rgba2, float percent)
public static int interpolateColor(int rgba1, int rgba2, float percent)
//package com.java2s; //License from project: Mozilla Public License public class Main { public static int interpolateColor(int rgba1, int rgba2, float percent) { int r1 = rgba1 & 0xFF, g1 = rgba1 >> 8 & 0xFF, b1 = rgba1 >> 16 & 0xFF, a1 = rgba1 >> 24 & 0xFF; int r2 = rgba2 & 0xFF, g2 = rgba2 >> 8 & 0xFF, b2 = rgba2 >> 16 & 0xFF, a2 = rgba2 >> 24 & 0xFF; int r = (int) (r1 < r2 ? r1 + (r2 - r1) * percent : r2 + (r1 - r2) * percent); int g = (int) (g1 < g2 ? g1 + (g2 - g1) * percent : g2 + (g1 - g2) * percent); int b = (int) (b1 < b2 ? b1 + (b2 - b1) * percent : b2 + (b1 - b2) * percent); int a = (int) (a1 < a2 ? a1 + (a2 - a1) * percent : a2 + (a1 - a2) * percent); return r | g << 8 | b << 16 | a << 24; }//from w w w. ja v a2s . c o m }