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

The following examples show how to use javafx.scene.paint.Color#getHue() . 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: Helper.java    From OEE-Designer with MIT License 5 votes vote down vote up
public static final Color[] createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
	int noOfColors = clamp(1, 12, NO_OF_COLORS);
	double step = 0.8 / noOfColors;
	double hue = COLOR.getHue();
	double brg = COLOR.getBrightness();
	Color[] colors = new Color[noOfColors];
	for (int i = 0; i < noOfColors; i++) {
		colors[i] = Color.hsb(hue, 0.2 + i * step, brg);
	}
	return colors;
}
 
Example 2
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 3
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 4
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final List<Color> createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
    int    noOfColors  = clamp(1, 5, NO_OF_COLORS);
    double step        = 0.8 / noOfColors;
    double hue         = COLOR.getHue();
    double brg         = COLOR.getBrightness();
    List<Color> colors = new ArrayList<>(noOfColors);
    for (int i = 0 ; i < noOfColors ; i++) { colors.add(Color.hsb(hue, 0.2 + i * step, brg)); }
    return colors;
}
 
Example 5
Source File: Helper.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public static final Color[] createColorVariations(final Color COLOR, final int NO_OF_COLORS) {
    int    noOfColors = clamp(1, 12, NO_OF_COLORS);
    double step       = 0.8 / noOfColors;
    double hue        = COLOR.getHue();
    double brg        = COLOR.getBrightness();
    Color[] colors = new Color[noOfColors];
    for (int i = 0 ; i < noOfColors ; i++) { colors[i] = Color.hsb(hue, 0.2 + i * step, brg); }
    return colors;
}
 
Example 6
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;
}