Here you can find the source of generateFireMapColor(double min, double max, double value)
Parameter | Description |
---|---|
min | min value in regard to value |
max | max value in regard to value |
value | the value passed in |
public static Color generateFireMapColor(double min, double max, double value)
//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); } }