Java interpolate interpolateColor(int c1, int c2, int st, int sts)

Here you can find the source of interpolateColor(int c1, int c2, int st, int sts)

Description

interpolate Color

License

Open Source License

Declaration

public static int interpolateColor(int c1, int c2, int st, int sts) 

Method Source Code

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

public class Main {
    public static int interpolateColor(int c1, int c2, int st, int sts) {
        return combine(interpolate(getR(c1), getR(c2), st, sts), interpolate(getG(c1), getG(c2), st, sts),
                interpolate(getB(c1), getB(c2), st, sts));
    }/*from  www  .  j  a  v  a 2 s.c o m*/

    public static int combine(int r, int g, int b) {
        int rgb = (r & 0xFF) << 16 | (g & 0xFF) << 8 | b & 0xFF;
        return rgb;
    }

    public static int interpolate(float firstColor, float secondColor, float stage, float maxStages) {
        return (int) (firstColor + (secondColor - firstColor) * stage / maxStages);
    }

    public static int getR(int color) {
        return color >> 16 & 255;
    }

    public static int getG(int color) {
        return color >> 8 & 255;
    }

    public static int getB(int color) {
        return color & 255;
    }
}

Related

  1. interpolateAO(float a, float b, float c, float d)
  2. interpolateBrightness(int a, int b, int c, int d)
  3. interpolateClamp(final double position, final double startPosition, final double endPosition, final double startValue, final double endValue)
  4. interpolateColor(double x, double y, int c0, int c1, int c2, int c3)
  5. interpolateColor(int a, int b, float w)
  6. interpolateColor(int rgba1, int rgba2, float percent)
  7. interpolateColors(int a, int b, float lerp)
  8. interpolateColors(int c0, int c1, float w)
  9. interpolateCubic(int x0, int x1, int x2, int x3, double t)