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


Java Color.getOpacity方法代碼示例

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


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

示例1: createColorPalette

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final List<Color> createColorPalette(final Color FROM_COLOR, final Color TO_COLOR, final int NO_OF_COLORS) {
    int    steps        = clamp(1, 50, NO_OF_COLORS) - 1;
    double step         = 1.0 / steps;
    double deltaRed     = (TO_COLOR.getRed()     - FROM_COLOR.getRed())     * step;
    double deltaGreen   = (TO_COLOR.getGreen()   - FROM_COLOR.getGreen())   * step;
    double deltaBlue    = (TO_COLOR.getBlue()    - FROM_COLOR.getBlue())    * step;
    double deltaOpacity = (TO_COLOR.getOpacity() - FROM_COLOR.getOpacity()) * step;

    List<Color> palette      = new ArrayList<>(NO_OF_COLORS);
    Color       currentColor = FROM_COLOR;
    palette.add(currentColor);
    for (int i = 0 ; i < steps ; i++) {
        double red     = clamp(0d, 1d, (currentColor.getRed()     + deltaRed));
        double green   = clamp(0d, 1d, (currentColor.getGreen()   + deltaGreen));
        double blue    = clamp(0d, 1d, (currentColor.getBlue()    + deltaBlue));
        double opacity = clamp(0d, 1d, (currentColor.getOpacity() + deltaOpacity));
        currentColor   = Color.color(red, green, blue, opacity);
        palette.add(currentColor);
    }
    return palette;
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:22,代碼來源:Helper.java

示例2: updateHeatMap

import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
 * Recreates the heatmap based on the current monochrome map.
 * Using this approach makes it easy to change the used color
 * mapping.
 */
private void updateHeatMap() {
    monochrome.snapshot(SNAPSHOT_PARAMETERS, monochromeImage);
    heatMap = new WritableImage(monochromeImage.widthProperty().intValue(), monochromeImage.heightProperty().intValue());
    Color       colorFromMonoChromeImage;
    double      brightness;
    Color       mappedColor;
    PixelWriter pixelWriter = heatMap.getPixelWriter();
    PixelReader pixelReader = monochromeImage.getPixelReader();
    int width  = (int) monochromeImage.getWidth();
    int height = (int) monochromeImage.getHeight();
    for (int y = 0 ; y < height ; y++) {
        for (int x = 0 ; x < width ; x++) {
            colorFromMonoChromeImage = pixelReader.getColor(x, y);
            brightness               = colorFromMonoChromeImage.getOpacity();
            mappedColor              = getColorAt(mappingGradient, brightness);
            pixelWriter.setColor(x, y, fadeColors ? Color.color(mappedColor.getRed(), mappedColor.getGreen(), mappedColor.getBlue(), brightness) : mappedColor);
        }
    }
    setImage(heatMap);
}
 
開發者ID:HanSolo,項目名稱:worldheatmap,代碼行數:26,代碼來源:HeatMap.java

示例3: updateHeatMap

import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
 * Recreates the heatmap based on the current monochrome map.
 * Using this approach makes it easy to change the used color
 * mapping.
 */
private void updateHeatMap() {
    monochrome.snapshot(SNAPSHOT_PARAMETERS, monochromeImage);

    int width  = monochromeImage.widthProperty().intValue();
    int height = monochromeImage.heightProperty().intValue();
    heatMap    = new WritableImage(width, height);

    Color       colorFromMonoChromeImage;
    double      brightness;
    Color       mappedColor;
    PixelWriter pixelWriter = heatMap.getPixelWriter();
    PixelReader pixelReader = monochromeImage.getPixelReader();
    for (int y = 0 ; y < height ; y++) {
        for (int x = 0 ; x < width ; x++) {
            colorFromMonoChromeImage = pixelReader.getColor(x, y);
            brightness               = colorFromMonoChromeImage.getOpacity();
            mappedColor              = Helper.getColorAt(mappingGradient, brightness);
            pixelWriter.setColor(x, y, fadeColors ? Color.color(mappedColor.getRed(), mappedColor.getGreen(), mappedColor.getBlue(), brightness) : mappedColor);
        }
    }
    setImage(heatMap);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:28,代碼來源:HeatMap.java

示例4: rgbColor

import javafx.scene.paint.Color; //導入方法依賴的package包/類
private static String rgbColor(Color color) {
    final int r = (int) (color.getRed()*255);
    final int g = (int) (color.getGreen()*255);
    final int b = (int) (color.getBlue()*255);
    final double a = color.getOpacity();
    return String.format("rgba(\"%d, %d, %d, %1.1f\")", r ,g, b, a);
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:8,代碼來源:DerivationController.java

示例5: 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

示例6: interpolateColor

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public static final Color interpolateColor(final Color COLOR1, final Color COLOR2, final double FRACTION, final double TARGET_OPACITY) {
    double fraction       = clamp(0, 1, FRACTION);
    double targetOpacity  = TARGET_OPACITY < 0 ? TARGET_OPACITY : clamp(0, 1, FRACTION);

    final double RED1     = COLOR1.getRed();
    final double GREEN1   = COLOR1.getGreen();
    final double BLUE1    = COLOR1.getBlue();
    final double OPACITY1 = COLOR1.getOpacity();

    final double RED2     = COLOR2.getRed();
    final double GREEN2   = COLOR2.getGreen();
    final double BLUE2    = COLOR2.getBlue();
    final double OPACITY2 = COLOR2.getOpacity();

    final double DELTA_RED     = RED2 - RED1;
    final double DELTA_GREEN   = GREEN2 - GREEN1;
    final double DELTA_BLUE    = BLUE2 - BLUE1;
    final double DELTA_OPACITY = OPACITY2 - OPACITY1;

    double red     = RED1 + (DELTA_RED * fraction);
    double green   = GREEN1 + (DELTA_GREEN * fraction);
    double blue    = BLUE1 + (DELTA_BLUE * fraction);
    double opacity = targetOpacity < 0 ? OPACITY1 + (DELTA_OPACITY * fraction) : targetOpacity;

    red     = clamp(0, 1, red);
    green   = clamp(0, 1, green);
    blue    = clamp(0, 1, blue);
    opacity = clamp(0, 1, opacity);

    return Color.color(red, green, blue, opacity);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:32,代碼來源:Helper.java

示例7: from

import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
 * Convert a color from {@link Color} to {@link ColorRGBA}.
 *
 * @param color the color
 * @return the jme color
 */
@FXThread
public static @Nullable ColorRGBA from(@Nullable final Color color) {
    if (color == null) return null;
    return new ColorRGBA((float) color.getRed(), (float) color.getGreen(),
            (float) color.getBlue(), (float) color.getOpacity());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:13,代碼來源:UIUtils.java

示例8: SColor

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public SColor(Color color) {
	this.red = color.getRed();
	this.green = color.getGreen();
	this.blue = color.getBlue();
	this.alpha = color.getOpacity();
}
 
開發者ID:lukasbischof,項目名稱:Orsum-occulendi,代碼行數:7,代碼來源:SColor.java

示例9: setVal

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public void setVal(Color color) {
	this.red = color.getRed();
	this.green = color.getGreen();
	this.blue = color.getBlue();
	this.alpha = color.getOpacity();
}
 
開發者ID:lukasbischof,項目名稱:Orsum-occulendi,代碼行數:7,代碼來源:SColor.java

示例10: Light

import javafx.scene.paint.Color; //導入方法依賴的package包/類
public Light(Color color) {
	this(color.getRed(), color.getGreen(), color.getBlue(), color.getOpacity());
}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:4,代碼來源:Light.java


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