Here you can find the source of decodeColor(final double v)
Parameter | Description |
---|---|
v | the double value completely describing the color |
public static final Color decodeColor(final double v)
//package com.java2s; // GNU LESSER GENERAL PUBLIC LICENSE (Version 2.1, February 1999) import java.awt.Color; public class Main { /** the alpha frequency */ private static final double A_FREQ = (2 * Math.PI); /** the red frequency */ private static final double R_FREQ = A_FREQ + 1d; /** the green frequency */ private static final double G_FREQ = R_FREQ + 1d; /** the blue frequency */ private static final double B_FREQ = G_FREQ + 1d; /**/*from www. j ava 2 s . c om*/ * Convert a double value to a color. The value v can be more or less * arbitrary and is translated to a color and alpha value. * * @param v * the double value completely describing the color * @return the color */ public static final Color decodeColor(final double v) { if (Double.isInfinite(v) || Double.isNaN(v)) { return Color.BLACK; } return new Color(// isin(v, R_FREQ), // isin(v, G_FREQ), // isin(v, B_FREQ), // isin(v, A_FREQ)); } /** * The internal sinus conversion function * * @param x * the x coordinate * @param f * the frequency * @return the sinus */ private static final float isin(final double x, final double f) { return Math.min(1f, Math.max(0f, (float) (0.5d + Math.sin(x * f)))); } }