Example usage for javafx.scene.paint Color getHue

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

Introduction

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

Prototype

public double getHue() 

Source Link

Document

Gets the hue 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.co m
    }
}