Here you can find the source of interpolate(final Color aBaseColor, final Color aSecondaryColor, final float aDelta)
Parameter | Description |
---|---|
aBaseColor | a parameter |
aSecondaryColor | a parameter |
aDelta | a parameter |
public static Color interpolate(final Color aBaseColor, final Color aSecondaryColor, final float aDelta)
//package com.java2s; /*//from w ww . ja va 2s . c om * OpenBench LogicSniffer / SUMP project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * * Copyright (C) 2010-2011 - J.W. Janssen, <http://www.lxtreme.nl> */ import java.awt.*; public class Main { /** * Interpolates a gray-scale color between two given colors. * * @param aBaseColor * @param aSecondaryColor * @param aDelta * @return */ public static Color interpolate(final Color aBaseColor, final Color aSecondaryColor, final float aDelta) { float[] acomp = aSecondaryColor.getRGBComponents(null); float[] bcomp = aBaseColor.getRGBComponents(null); float[] ccomp = new float[4]; for (int i = 0; i < 4; i++) { ccomp[i] = acomp[i] + ((bcomp[i] - acomp[i]) * aDelta); } return new Color(ccomp[0], ccomp[1], ccomp[2], ccomp[3]); } }