Here you can find the source of interpolate(int v1, int v2, float f)
public static int interpolate(int v1, int v2, float f)
//package com.java2s; public class Main { public static int interpolate(int v1, int v2, float f) { return clamp((int) (v1 + f * (v2 - v1))); }// w w w. j a v a 2s . c o m /** * Clamp a value to the range 0..255 */ public static int clamp(int c) { if (c < 0) return 0; if (c > 255) return 255; return c; } }