Java Code Examples for javafx.scene.paint.Color#getBlue()
The following examples show how to use
javafx.scene.paint.Color#getBlue() .
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: DifferenceHash.java From JImageHash with MIT License | 6 votes |
private int drawDoublePrecision(FastPixel writer, int width, int wOffset, int height, int hOffset, int blockSize, int offset, int yOffset, int[] bitColorIndex, Color[] colors) { int i = offset; for (int w = 0; w < (width - wOffset) * blockSize; w = w + blockSize) { for (int h = 0; h < (height - hOffset) * blockSize; h = h + blockSize) { Color c = colors[bitColorIndex[i++]]; int red = (int) (c.getRed() * 255); int green = (int) (c.getGreen() * 255); int blue = (int) (c.getBlue() * 255); for (int m = 0; m < blockSize; m++) { for (int n = 0; n < blockSize; n++) { int x = w + m; int y = h + n + yOffset * blockSize; // bi.setRGB(y, x, bit ? black : white); writer.setRed(x, y, red); writer.setGreen(x, y, green); writer.setBlue(x, y, blue); } } } } return i-offset; }
Example 2
Source File: DefaultControlTreeItemGraphic.java From arma-dialog-creator with MIT License | 6 votes |
private void fillBox(Color color) { GraphicsContext gc = box.getGraphicsContext2D(); gc.save(); gc.clearRect(0, 0, box.getWidth(), box.getHeight()); gc.setFill(color); gc.fillRect(0, 0, box.getWidth(), box.getHeight()); gc.restore(); //generate hex string and bind it to tooltip final double f = 255.0; int r = (int) (color.getRed() * f); int g = (int) (color.getGreen() * f); int b = (int) (color.getBlue() * f); String opacity = DecimalFormat.getNumberInstance().format(color.getOpacity() * 100); Tooltip.install(box, new Tooltip(String.format( "red:%d, green:%d, blue:%d, opacity:%s%%", r, g, b, opacity)) ); }
Example 3
Source File: Helper.java From OEE-Designer with MIT License | 6 votes |
public static final List<Color> createColorPalette(final Color FROM_COLOR, final Color TO_COLOR, final int NO_OF_COLORS) { int steps = clamp(1, 12, 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; }
Example 4
Source File: Helper.java From tilesfx with Apache License 2.0 | 6 votes |
public static final List<Color> createColorPalette(final Color FROM_COLOR, final Color TO_COLOR, final int NO_OF_COLORS) { int steps = clamp(1, 12, 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; }
Example 5
Source File: FXColorPicker.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Opens a {@link ColorDialog} to let the user pick a {@link Color}. Returns * the picked {@link Color}, or <code>null</code> if no color was picked. * * @param shell * The {@link Shell} which serves as the parent for the * {@link ColorDialog}. * @param initial * The initial {@link Color} to display in the * {@link ColorDialog}. * @return The picked {@link Color}, or <code>null</code>. */ protected static Color pickColor(Shell shell, Color initial) { ColorDialog cd = new ColorDialog(shell); RGB rgb = new RGB((int) (255 * initial.getRed()), (int) (255 * initial.getGreen()), (int) (255 * initial.getBlue())); cd.setRGB(rgb); RGB newRgb = cd.open(); if (newRgb != null) { return Color.rgb(newRgb.red, newRgb.green, newRgb.blue); } return null; }
Example 6
Source File: GradientLookup.java From regulators with Apache License 2.0 | 5 votes |
public double getValueFrom(final Color COLOR) { if (stops.isEmpty()) return 0; double red = COLOR.getRed(); double green = COLOR.getGreen(); double blue = COLOR.getBlue(); for (double i = 0 ; Double.compare(i, 1.0) <= 0 ; i += 0.01) { Color color = getColorAt(i); if(Math.abs(red - color.getRed()) < 0.05 && Math.abs(green - color.getGreen()) < 0.05 && Math.abs(blue - color.getBlue()) < 0.05) { return i; } } return 0; }
Example 7
Source File: HeatTabController.java From marathonv5 with Apache License 2.0 | 5 votes |
/** * Helper function to convert a color in sRGB space to linear RGB space. */ public static Color convertSRGBtoLinearRGB(Color color) { double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() }; for (int i=0; i<colors.length; i++) { if (colors[i] <= 0.04045) { colors[i] = colors[i] / 12.92; } else { colors[i] = Math.pow((colors[i] + 0.055) / 1.055, 2.4); } } return Color.color(colors[0], colors[1], colors[2], color.getOpacity()); }
Example 8
Source File: Helper.java From charts with Apache License 2.0 | 5 votes |
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); }
Example 9
Source File: Helper.java From charts with Apache License 2.0 | 5 votes |
public static final Color getColorWithOpacity(final Color COLOR, final double OPACITY) { double red = COLOR.getRed(); double green = COLOR.getGreen(); double blue = COLOR.getBlue(); double opacity = clamp(0, 1, OPACITY); return Color.color(red, green, blue, opacity); }
Example 10
Source File: ColorUtilty.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * * @param color JavaFX color * @return AWT color */ @Nullable public static java.awt.Color colorToAWTColor(final Color color) { if (color == null) { return null; } return new java.awt.Color( (int) (color.getRed() * 255), (int) (color.getGreen() * 255), (int) (color.getBlue() * 255) ); }
Example 11
Source File: Util.java From Enzo with Apache License 2.0 | 5 votes |
public static Image createGrayNoise(final double WIDTH, final double HEIGHT, final Color DARK_COLOR, final Color BRIGHT_COLOR) { if (WIDTH <= 0 || HEIGHT <= 0) { return null; } final WritableImage IMAGE = new WritableImage((int) WIDTH, (int) HEIGHT); final PixelWriter PIXEL_WRITER = IMAGE.getPixelWriter(); final Random RND = new Random(); double redDark = DARK_COLOR.getRed(); double greenDark = DARK_COLOR.getGreen(); double blueDark = DARK_COLOR.getBlue(); double redBright = DARK_COLOR.getRed(); double greenBright = DARK_COLOR.getGreen(); double blueBright = DARK_COLOR.getBlue(); int startRed = (int) (Math.min(redDark, redBright) * 255); int startGreen = (int) (Math.min(greenDark, greenBright) * 255); int startBlue = (int) (Math.min(blueDark, blueBright) * 255); int start = returnLargest(startRed, startGreen, startBlue); int deltaRed = Math.abs((int) ((BRIGHT_COLOR.getRed() - DARK_COLOR.getRed()) * 255)); int deltaGreen = Math.abs((int) ((BRIGHT_COLOR.getGreen() - DARK_COLOR.getGreen()) * 255)); int deltaBlue = Math.abs((int) ((BRIGHT_COLOR.getBlue() - DARK_COLOR.getBlue()) * 255)); int delta = returnLargest(deltaRed, deltaGreen, deltaBlue); int gray; for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { gray = delta > 0 ? start + RND.nextInt(delta) : start; PIXEL_WRITER.setColor(x, y, Color.rgb(clamp(0, 255, gray), clamp(0, 255, gray), clamp(0, 255, gray))); } } return IMAGE; }
Example 12
Source File: Helper.java From OEE-Designer with MIT License | 5 votes |
public static final double colorDistance(final Color COLOR_1, final Color COLOR_2) { final double DELTA_R = (COLOR_2.getRed() - COLOR_1.getRed()); final double DELTA_G = (COLOR_2.getGreen() - COLOR_1.getGreen()); final double DELTA_B = (COLOR_2.getBlue() - COLOR_1.getBlue()); return Math.sqrt(DELTA_R * DELTA_R + DELTA_G * DELTA_G + DELTA_B * DELTA_B); }
Example 13
Source File: JFXColorPickerUI.java From JFoenix with Apache License 2.0 | 5 votes |
private void setColorAtLocation(int x, int y) { if (allowColorChange) { Color color = getColorAtLocation(x, y); String colorString = "rgb(" + color.getRed() * 255 + "," + color.getGreen() * 255 + "," + color.getBlue() * 255 + ");"; for (Node node : colorNodes) node.setStyle("-fx-background-color:" + colorString + "; -fx-fill:" + colorString+";"); } }
Example 14
Source File: UiUtils.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Convert the color to hex presentation to use in web. * * @param color the color. * @return the web presentation. */ @FromAnyThread public static @NotNull String toWeb(@NotNull final Color color) { final int red = (int) (color.getRed() * 255); final int green = (int) (color.getGreen() * 255); final int blue = (int) (color.getBlue() * 255); return "#" + Integer.toHexString(red) + Integer.toHexString(green) + Integer.toHexString(blue); }
Example 15
Source File: TextStyle.java From RichTextFX with BSD 2-Clause "Simplified" License | 4 votes |
static String cssColor(Color color) { int red = (int) (color.getRed() * 255); int green = (int) (color.getGreen() * 255); int blue = (int) (color.getBlue() * 255); return "rgb(" + red + ", " + green + ", " + blue + ")"; }
Example 16
Source File: FxmlColor.java From MyBox with Apache License 2.0 | 4 votes |
public static String rgb2css(Color color) { return "rgba(" + (int) (color.getRed() * 255) + "," + (int) (color.getGreen() * 255) + "," + (int) (color.getBlue() * 255) + "," + color.getOpacity() + ")"; }
Example 17
Source File: NumberColorMapTest.java From diirt with MIT License | 4 votes |
private int getRGB(Color c){ int red = (int)(255*c.getRed()); int green = (int)(255*c.getGreen()); int blue = (int)(255*c.getBlue()); return (255 << 24) | (red<< 16) | (green<< 8) | blue; }
Example 18
Source File: ColorPickerSample.java From marathonv5 with Apache License 2.0 | 4 votes |
private String createRGBString(Color c) { return "-fx-base: rgb(" + (c.getRed() * 255) + "," + (c.getGreen() * 255) + "," + (c.getBlue() * 255) + ");"; }
Example 19
Source File: SVColorArray.java From arma-dialog-creator with MIT License | 4 votes |
/** Set the color from a JavaFX Color instance */ public SVColorArray(@NotNull Color newValue) { this(newValue.getRed(), newValue.getGreen(), newValue.getBlue(), newValue.getOpacity()); }
Example 20
Source File: ColorGradientAxis.java From chart-fx with Apache License 2.0 | 2 votes |
/** * Return the color for a value as an integer with the color values in its bytes. For use e.g. with an IntBuffer * backed PixelBuffer. * * @param value z-Value * @return integer with one byte each set to alpha, red, green, blue */ public int getIntColor(final double value) { final Color color = getColor(value); return ((byte) (color.getOpacity() * 255) << 24) + ((byte) (color.getRed() * 255) << 16) + ((byte) (color.getGreen() * 255) << 8) + ((byte) (color.getBlue() * 255)); }