Java Color Interpolate interpolate(double factor, Color bottomCol, Color topCol)

Here you can find the source of interpolate(double factor, Color bottomCol, Color topCol)

Description

interpolate

License

Open Source License

Declaration

public static String interpolate(double factor, Color bottomCol, Color topCol) 

Method Source Code


//package com.java2s;
import java.awt.Color;

public class Main {
    public static String interpolate(double factor, Color bottomCol, Color topCol) {
        int red, blue, green;

        red = (int) Math.round((1.0 - factor) * bottomCol.getRed() + factor * topCol.getRed());
        blue = (int) Math.round((1.0 - factor) * bottomCol.getBlue() + factor * topCol.getBlue());
        green = (int) Math.round((1.0 - factor) * bottomCol.getGreen() + factor * topCol.getGreen());

        Color color = new Color(Math.min(red, 255), Math.min(green, 255), Math.min(blue, 255));

        return Integer.toHexString(color.getRGB()).substring(2, 8);
    }//from   w  w  w  . j  av a2  s.c o  m
}

Related

  1. interpolate(Color b, Color a, float t)
  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)
  6. interpolate(double x, double y, float[] colorLL, float[] colorLR, float[] colorUL, float[] colorUR)
  7. interpolate(final Color aBaseColor, final Color aSecondaryColor, final float aDelta)
  8. interpolate(final Color from, final Color to, final double t)
  9. interpolate(java.awt.Color a, java.awt.Color b, float portion)