當前位置: 首頁>>代碼示例>>Java>>正文


Java Color.getBrightness方法代碼示例

本文整理匯總了Java中javafx.scene.paint.Color.getBrightness方法的典型用法代碼示例。如果您正苦於以下問題:Java Color.getBrightness方法的具體用法?Java Color.getBrightness怎麽用?Java Color.getBrightness使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.paint.Color的用法示例。


在下文中一共展示了Color.getBrightness方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createColorVariations

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final 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();
    Color[] colors = new Color[noOfColors];
    for (int i = 0 ; i < noOfColors ; i++) { colors[i] = Color.hsb(hue, 0.2 + i * step, brg); }
    return colors;
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:10,代碼來源:Helper.java

示例2: getColorRangeMinMax

import javafx.scene.paint.Color; //導入方法依賴的package包/類
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 };
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:12,代碼來源:Helper.java

示例3: updateUI

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public void updateUI(final Color color) {
    double hue = color.getHue();
    double saturation = color.getSaturation();
    double brightness = color.getBrightness();
    double alpha = color.getOpacity();
    updateUI(hue, saturation, brightness, alpha);
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:8,代碼來源:ColorPickerControl.java

示例4: updateUI_OnRGBChange

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private Color updateUI_OnRGBChange() {
    // retrieve RGB TextFields values
    int red = Double.valueOf(red_textfield.getText()).intValue();
    int green = Double.valueOf(green_textfield.getText()).intValue();
    int blue = Double.valueOf(blue_textfield.getText()).intValue();
    // retrieve HSB values from RGB values
    final Color color = Color.rgb(red, green, blue);
    double hue = color.getHue();
    double saturation = color.getSaturation();
    double brightness = color.getBrightness();
    double alpha = Double.valueOf(alpha_textfield.getText());
    return updateUI(hue, saturation, brightness, alpha);
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:14,代碼來源:ColorPickerControl.java

示例5: updateUI_OnHexaChange

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private Color updateUI_OnHexaChange() {
    // retrieve Hexa TextField value
    final String hexa = hexa_textfield.getText().trim();
    final Color color = Color.web(hexa);
    double hue = color.getHue();
    double saturation = color.getSaturation();
    double brightness = color.getBrightness();
    double alpha = Double.valueOf(alpha_textfield.getText());
    return updateUI(hue, saturation, brightness, alpha);
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:11,代碼來源:ColorPickerControl.java

示例6: createColorVariations

import javafx.scene.paint.Color; //導入方法依賴的package包/類
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;
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:10,代碼來源:Helper.java

示例7: updateReverseDerivation

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private void updateReverseDerivation() {
        Color desiredColor = (Color) desiredPicker.getPaint();
        final Color base = (Color) basePicker.getPaint();
//                System.out.println("base = " + base);
        double desiredBrightness = desiredColor.getBrightness();
//                System.out.println("desiredBrightness = " + desiredBrightness);
        //    double desiredSaturation = desiredColor.getSaturation();
//                System.out.println("desiredSaturation = " + desiredSaturation);
        double derivation = 0, max = 1, min = -1;
        Color derivedColor = Color.WHITE;
        for (int i = 0; i < 100; i++) {
//                    System.out.println("---------- "+i+" ----------------");
//                    System.out.println("derivation = " + derivation);
//                    System.out.println("max = " + max);
//                    System.out.println("min = " + min);
            derivedColor = ColorEncoder.deriveColor(base, derivation);
            double derivedBrightness = derivedColor.getBrightness();
//                    System.out.println("derivedBrightness = " + derivedBrightness);
            //    double derivedSaturation = derivedColor.getSaturation();
//                    System.out.println("derivedSaturation = " + derivedSaturation);
            //     double saturationDifference = Math.abs(derivedSaturation-desiredSaturation);
//                    System.out.println("saturationDifference = " + saturationDifference);
            double difference = Math.abs(derivedBrightness - desiredBrightness);
//                    System.out.println("brightness difference = " + difference);
            if (difference < 0.0001) { // GOOD ENOUGH
                break;
            } else if (min == 1 || max == -1) { // TO DIFFERENT
                break;
            } else if (derivedBrightness > desiredBrightness) { // TO BRIGHT
//                        System.out.println("NEED DARKER");
                max = derivation;
                derivation = derivation + ((min - derivation) / 2);
            } else { // TO DARK
//                        System.out.println("NEED BRIGHTER");
                min = derivation;
                derivation = derivation + ((max - derivation) / 2);
            }
        }

//       System.out.println("\nFINAL \nderivation = " + derivation+"\n\n");
        reverseDerivationLabel.setText(String.format("%3.1f%%", derivation));
        hexReverseTextfield.setText(ColorEncoder.encodeColor(derivedColor).toUpperCase());
        rgbReverseTextfield.setText(rgbColor(derivedColor));
        reverseRegion.setStyle("-fx-border-color: black; "
                + "-fx-background-color: "+ ColorEncoder.getWebColor(derivedColor) +";");

//        alert.setVisible(!ColorEncoder.getWebColor(desiredColor).equals(ColorEncoder.getWebColor(derivedColor)));
    }
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:49,代碼來源:DerivationController.java


注:本文中的javafx.scene.paint.Color.getBrightness方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。