Example usage for javafx.scene.paint Color getBrightness

List of usage examples for javafx.scene.paint Color getBrightness

Introduction

In this page you can find the example usage for javafx.scene.paint Color getBrightness.

Prototype

public double getBrightness() 

Source Link

Document

Gets the brightness component of this Color .

Usage

From source file:org.nmrfx.processor.gui.spectra.DrawSpectrum.java

static void setColorGradient(final int nLevels, final boolean refresh, final Color color1, final Color color2) {
    if (refresh || (gradColors.length != nLevels)) {
        double hue1 = color1.getHue();
        double brightness1 = color1.getBrightness();
        double saturation1 = color1.getSaturation();
        double hue2 = color2.getHue();
        double brightness2 = color2.getBrightness();
        double saturation2 = color2.getSaturation();
        gradColors = new Color[nLevels];
        for (int iColor = 0; iColor < nLevels; iColor++) {
            double f = ((double) iColor) / (nLevels - 1);
            double h = hue1 + (hue2 - hue1) * f;
            double s = saturation1 + (saturation2 - saturation1) * f;
            double b = brightness1 + (brightness2 - brightness1) * f;
            gradColors[iColor] = Color.hsb(h, s, b);
        }/* w  w w. j  a v a 2  s  .c  o  m*/
    }
}