Java Array Interpolate interpolateColor(float[] result, float[] color0, float[] color1, double s)

Here you can find the source of interpolateColor(float[] result, float[] color0, float[] color1, double s)

Description

Computes (1-s) color0 + s color1 and places the result in result.

License

BSD License

Parameter

Parameter Description
result result value
color0 first color
color1 second color
s interpolation parameter

Declaration

public static void interpolateColor(float[] result, float[] color0, float[] color1, double s) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**/*from www.j av  a2s.c o  m*/
     * Computes <code>(1-s) color0 + s color1</code> and places the result
     * in <code>result</code>. Only the first three array entries are used.
     * 
     * @param result result value
     * @param color0 first color
     * @param color1 second color
     * @param s interpolation parameter
     */
    public static void interpolateColor(float[] result, float[] color0, float[] color1, double s) {

        float a = (float) (1 - s);
        float b = (float) (s);

        result[0] = a * color0[0] + b * color1[0];
        result[1] = a * color0[1] + b * color1[1];
        result[2] = a * color0[2] + b * color1[2];
    }
}

Related

  1. interpolate(double[] x, int newLength)
  2. interpolate(float out[], float in1[], float in2[], int in2_idx, float coef, int length)
  3. interpolate(int[] data, double x)
  4. interpolate_linear(int[] x, double[] y, int[] xi)
  5. interpolateArray(int[] array, int interval)
  6. interpolateLinear(int[] v1, int[] v2, double t)
  7. interpolateLinear(int[] vec, int start, int end)
  8. interpolateNonZeroValues(double[] contour)