Converts a scalar normalized to de range [0:1] into a yellow to red map. - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

Converts a scalar normalized to de range [0:1] into a yellow to red map.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        float value = 2.45678f;
        float[] rgba = new float[] { 34.45f, 35.45f, 36.67f, 37.78f,
                37.0000f, 37.1234f, 67.2344f, 68.34534f, 69.87700f };
        yellow_to_red(value, rgba);// w  w  w. j  a va2s. c  o  m
    }

    /**
     * Converts a scalar normalized to de range [0:1] into
     * a yellow to red map. 
     * See: http://www.particleincell.com/blog/2014/colormap/
     * @param value
     * @return
     */
    public static void yellow_to_red(float value, float[] rgba) {
        rgba[0] = 1;
        rgba[1] = value;
        rgba[2] = 0;
    }
}

Related Tutorials