Java Color Interpolate interpolate(Color b, Color a, float t)

Here you can find the source of interpolate(Color b, Color a, float t)

Description

interpolate

License

Open Source License

Declaration

public static Color interpolate(Color b, Color a, float t) 

Method Source Code

//package com.java2s;
/*/*from  ww  w . ja  v a2  s.  c  om*/
 * #%L
 * The AIBench Plugin Manager Plugin
 * %%
 * Copyright (C) 2006 - 2016 Daniel Glez-Pe?a and Florentino Fdez-Riverola
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 * #L%
 */

import java.awt.Color;

public class Main {
    public static Color interpolate(Color b, Color a, float t) {
        float[] acomp = a.getRGBComponents(null);
        float[] bcomp = b.getRGBComponents(null);
        float[] ccomp = new float[4];

        //        log.fine(("a comp ");
        //        for(float f : acomp) {
        //            log.fine((f);
        //        }
        //        for(float f : bcomp) {
        //            log.fine((f);
        //        }
        for (int i = 0; i < 4; i++) {
            ccomp[i] = acomp[i] + (bcomp[i] - acomp[i]) * t;
        }
        //        for(float f : ccomp) {
        //            log.fine((f);
        //        }

        return new Color(ccomp[0], ccomp[1], ccomp[2], ccomp[3]);
    }
}

Related

  1. interpolate(Color a, Color b, float f)
  2. interpolate(Color c1, Color c2, float fracFromC1)
  3. interpolate(Color colour1, Color colour2, float colour2Fraction)
  4. interpolate(Color low, Color high, double min, double max, double v)
  5. interpolate(Color start, Color end, float p)