Here you can find the source of interpolate(Color c1, Color c2, float fracFromC1)
Parameter | Description |
---|---|
c1 | the first colour |
c2 | the second colour |
fracFromC1 | the fraction of the final colour that will come from c1 |
private static Color interpolate(Color c1, Color c2, float fracFromC1)
//package com.java2s; import java.awt.Color; public class Main { /**// w w w .j av a 2 s .co m * Linearly interpolates between two RGB colours * * @param c1 * the first colour * @param c2 * the second colour * @param fracFromC1 * the fraction of the final colour that will come from c1 * @return the interpolated Color */ private static Color interpolate(Color c1, Color c2, float fracFromC1) { float fracFromC2 = 1.0f - fracFromC1; return new Color(Math.round(fracFromC1 * c1.getRed() + fracFromC2 * c2.getRed()), Math.round(fracFromC1 * c1.getGreen() + fracFromC2 * c2.getGreen()), Math.round(fracFromC1 * c1.getBlue() + fracFromC2 * c2.getBlue()), Math.round(fracFromC1 * c1.getAlpha() + fracFromC2 * c2.getAlpha())); } }