Java Code Examples for javafx.scene.paint.Color#getSaturation()

The following examples show how to use javafx.scene.paint.Color#getSaturation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FxmlColor.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static int compareColor(Color o1, Color o2) {
    double diff = o2.getHue() - o1.getHue();
    if (diff > 0) {
        return 1;
    } else if (diff < 0) {
        return -1;
    } else {
        diff = o2.getSaturation() - o1.getSaturation();
        if (diff > 0) {
            return 1;
        } else if (diff < 0) {
            return -1;
        } else {
            diff = o2.getBrightness() - o1.getBrightness();
            if (diff > 0) {
                return 1;
            } else if (diff < 0) {
                return -1;
            } else {
                diff = o2.getOpacity() - o1.getOpacity();
                if (diff > 0) {
                    return 1;
                } else if (diff < 0) {
                    return -1;
                } else {
                    return 0;
                }
            }
        }
    }
}
 
Example 2
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final Color[] getColorRangeMinMax(final Color COLOR, final int STEPS) {
    double hue            = COLOR.getHue();
    double saturation     = COLOR.getSaturation();
    double brightness     = COLOR.getBrightness();
    double saturationStep = saturation / STEPS;
    double brightnessStep = brightness / STEPS;
    double halfSteps      = STEPS / 2;
    Color fromColor       = COLOR.hsb(hue, saturation, clamp(0, 1, brightness + brightnessStep * halfSteps));
    Color toColor         = COLOR.hsb(hue, saturation, clamp(0, 1, brightness - brightnessStep * halfSteps));
    return new Color[] { fromColor, toColor };
}
 
Example 3
Source File: LcdSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private Color[] getSectionColors(final Color LCD_BACKGROUND_COLOR, final Color LCD_FOREGROUND_COLOR) {
    double hue = LCD_BACKGROUND_COLOR.getHue();
    double sat = LCD_BACKGROUND_COLOR.getSaturation();

    Color[] colors;
    if (Helper.isMonochrome(LCD_BACKGROUND_COLOR)) {
        // Section color is monochrome
        colors = new Color[]{
            Color.hsb(hue, 0, 0.69),
            Color.hsb(hue, 0, 1.0),
            Color.hsb(hue, 0, 0.76),
            Color.hsb(hue, 0, 0.76),
            Color.hsb(hue, sat, 0.69),
            Helper.isDark(LCD_BACKGROUND_COLOR) ? Color.WHITE : Color.BLACK,
            Helper.isDark(LCD_BACKGROUND_COLOR) ? Color.rgb(255, 255, 255, 0.1) : Color.rgb(0, 0, 0, 0.1)
        };
    } else {
        // Section color is not monochrome
        colors = new Color[]{
            Color.hsb(hue, sat, 0.69),
            Color.hsb(hue, sat, 1.0),
            Color.hsb(hue, sat, 0.76),
            Color.hsb(hue, sat, 0.76),
            Color.hsb(hue, sat, 0.69),
            LCD_FOREGROUND_COLOR,
            Color.color(LCD_BACKGROUND_COLOR.getRed(), LCD_BACKGROUND_COLOR.getGreen(), LCD_BACKGROUND_COLOR.getBlue(), 0.1)
        };
    }
    return colors;
}