Java Color Interpolate interpolate(Color colour1, Color colour2, float colour2Fraction)

Here you can find the source of interpolate(Color colour1, Color colour2, float colour2Fraction)

Description

interpolate

License

Open Source License

Declaration

public static Color interpolate(Color colour1, Color colour2, float colour2Fraction) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

public class Main {
    public static Color interpolate(Color colour1, Color colour2, float colour2Fraction) {
        float[] hsb1 = new float[3];
        Color.RGBtoHSB(colour1.getRed(), colour1.getGreen(), colour1.getBlue(), hsb1);

        float[] hsb2 = new float[3];
        Color.RGBtoHSB(colour2.getRed(), colour2.getGreen(), colour2.getBlue(), hsb2);

        float h = hsb1[0] + (float) colour2Fraction * (hsb2[0] - hsb1[0]);
        float s = hsb1[1] + (float) colour2Fraction * (hsb2[1] - hsb1[1]);
        float b = hsb1[2] + (float) colour2Fraction * (hsb2[2] - hsb1[2]);
        return Color.getHSBColor(h, s, b);
    }//from   ww w  .  j av a 2 s.  c  o m
}

Related

  1. interpolate(Color a, Color b, float f)
  2. interpolate(Color b, Color a, float t)
  3. interpolate(Color c1, Color c2, float fracFromC1)
  4. interpolate(Color low, Color high, double min, double max, double v)
  5. interpolate(Color start, Color end, float p)
  6. interpolate(double factor, Color bottomCol, Color topCol)
  7. interpolate(double x, double y, float[] colorLL, float[] colorLR, float[] colorUL, float[] colorUR)