Java Color Create generateFireMapColor(double min, double max, double value)

Here you can find the source of generateFireMapColor(double min, double max, double value)

Description

generate Fire Map Color

License

Open Source License

Parameter

Parameter Description
min min value in regard to value
max max value in regard to value
value the value passed in

Return

a fire mapped (white, yellow, orange, red, black) color

Declaration

public static Color generateFireMapColor(double min, double max, double value) 

Method Source Code


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

import java.awt.*;

public class Main {
    /**/* w  w  w. j  ava  2s.c  o m*/
     * @param min   min value in regard to value
     * @param max   max value in regard to value
     * @param value the value passed in
     * @return a fire mapped (white, yellow, orange, red, black) color
     */
    public static Color generateFireMapColor(double min, double max, double value) {
        assert value >= min && value <= max;
        if (value < min || value > max) {
            throw new IllegalArgumentException("Value must be between min and max values, it was not.");
        }
        double power = (value - min) / (max - min); //will be between 0 and 1
        double H = Math.abs(0.138 - power * 0.138); //red-yellow
        double S = 1;
        double B = Math.abs(0.5 - power * 0.5) + 0.5; // Brightness
        return Color.getHSBColor((float) H, (float) S, (float) B);
    }
}

Related

  1. generateColor(int fc, int bc)
  2. generateColorFromString(String seed)
  3. generateColorModel()
  4. generateColorRamp(int n)
  5. generateColourSet(Color[] palette, int numColorBands)
  6. generateGrayScaleColor(double min, double max, double value)
  7. generateGreyColor(double value, double minValue, double maxValue)
  8. generateHexolor(Color color)
  9. generateNColors(int numColors)