本文整理匯總了Java中javafx.scene.paint.Color.getBlue方法的典型用法代碼示例。如果您正苦於以下問題:Java Color.getBlue方法的具體用法?Java Color.getBlue怎麽用?Java Color.getBlue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.paint.Color
的用法示例。
在下文中一共展示了Color.getBlue方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: convertSRGBtoLinearRGB
import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
* 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());
}
示例3: convertLinearRGBtoSRGB
import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
* Helper function to convert a color in linear RGB space to SRGB space.
*/
public static Color convertLinearRGBtoSRGB(Color color) {
double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() };
for (int i=0; i<colors.length; i++) {
if (colors[i] <= 0.0031308) {
colors[i] = colors[i] * 12.92;
} else {
colors[i] = (1.055 * Math.pow(colors[i], (1.0 / 2.4))) - 0.055;
}
}
return Color.color(colors[0], colors[1], colors[2], color.getOpacity());
}
示例4: copyColorToBytes
import javafx.scene.paint.Color; //導入方法依賴的package包/類
/**
* Copy pixels from image to byte array.
*
* @param argbData the argb pixels data.
* @param imageData the bytes pixels data.
*/
private void copyColorToBytes(final int[] argbData, final byte[] imageData) {
if (argbData.length * BYTES_PER_PIXEL != imageData.length) {
throw new ArrayIndexOutOfBoundsException();
}
final Color overrideColor = OVERRIDE_COLOR.get();
for (int i = 0; i < argbData.length; i++) {
final int argb = argbData[i];
int alpha = argb >>> 24;
int red = (argb >> 16) & 0xff;
int green = (argb >> 8) & 0xff;
int blue = (argb) & 0xff;
if (overrideColor != null) {
red = (int) (overrideColor.getRed() * 255);
green = (int) (overrideColor.getGreen() * 255);
blue = (int) (overrideColor.getBlue() * 255);
}
int dataOffset = BYTES_PER_PIXEL * i;
imageData[dataOffset] = (byte) red;
imageData[dataOffset + 1] = (byte) green;
imageData[dataOffset + 2] = (byte) blue;
imageData[dataOffset + 3] = (byte) alpha;
}
}
示例5: getColorWithOpacity
import javafx.scene.paint.Color; //導入方法依賴的package包/類
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);
}
示例6: 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);
}
示例7: getWebColor
import javafx.scene.paint.Color; //導入方法依賴的package包/類
private static String getWebColor(Color color) {
final int red = (int)(color.getRed()*255);
final int green = (int)(color.getGreen()*255);
final int blue = (int)(color.getBlue()*255);
return "#" + String.format("%02X", red) +
String.format("%02X", green) +
String.format("%02X", blue);
}
示例8: 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);
}
示例9: 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());
}
示例10: createRGBString
import javafx.scene.paint.Color; //導入方法依賴的package包/類
private String createRGBString(Color c) {
return "-fx-base: rgb(" + (c.getRed() * 255) + "," + (c.getGreen() * 255) + "," + (c.getBlue() * 255) + ");";
}
示例11: 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();
}
示例12: 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();
}
示例13: updateUI
import javafx.scene.paint.Color; //導入方法依賴的package包/類
private Color updateUI(double hue, double saturation, double brightness, double alpha) {
// Position the picker dot
double xSat = picker_region.getWidth() * saturation; // Saturation is on x axis
double yBri = picker_region.getHeight() * (1.0 - brightness); // Brightness is on y axis (reversed as white is top)
double xPos = (picker_region.getBoundsInParent().getMinX() + xSat) - picker_handle_stackpane.getWidth() / 2;
double yPos = (picker_region.getBoundsInParent().getMinY() + yBri) - picker_handle_stackpane.getHeight() / 2;
xPos = ColorEncoder.clamp(xPos, 0, picker_region.getPrefWidth() - (picker_handle_stackpane.getWidth()));
yPos = ColorEncoder.clamp(yPos, 0, picker_region.getPrefHeight() - (picker_handle_stackpane.getHeight()));
picker_handle_stackpane.setLayoutX(xPos);
picker_handle_stackpane.setLayoutY(yPos);
// update the HSB values so they are within range
saturation = ColorEncoder.clamp(0, saturation, 1);
brightness = ColorEncoder.clamp(0, brightness, 1);
// alpha = PaintPickerController.clamp(0, alpha, 1);
// make an rgb color from the hsb
final Color color = Color.hsb(hue, saturation, brightness, alpha);
int red = (int) (color.getRed() * 255);
int green = (int) (color.getGreen() * 255);
int blue = (int) (color.getBlue() * 255);
String hexa = ColorEncoder.encodeColor(color);
// Set TextFields value
hue_textfield.setText(String.valueOf((int) hue));
saturation_textfield.setText(String.valueOf((int) (saturation * 100)));
brightness_textfield.setText(String.valueOf((int) (brightness * 100)));
alpha_textfield.setText(Double.toString(alpha));
red_textfield.setText(Integer.toString(red));
green_textfield.setText(Integer.toString(green));
blue_textfield.setText(Integer.toString(blue));
hexa_textfield.setText(hexa.toUpperCase());
final String chipStyle = "-fx-background-color: " + hexa; //NOI18N
chip_region.setStyle(chipStyle);
picker_handle_chip_circle.setFill(Color.rgb(red, green, blue));
final String alphaChipStyle = "-fx-background-color: " //NOI18N
+ "linear-gradient(to right, transparent, " + hexa + ")"; //NOI18N
alpha_slider.setAlphaChipCSS(alphaChipStyle);
// Set the background color of the picker region
// (force saturation and brightness to 100% - don't add opacity)
final String pickerRegionStyle = "-fx-background-color: hsb(" //NOI18N
+ hue + ", 100%, 100%, 1.0);"; //NOI18N
picker_region.setStyle(pickerRegionStyle);
return color;
}
示例14: Light
import javafx.scene.paint.Color; //導入方法依賴的package包/類
public Light(Color color) {
this(color.getRed(), color.getGreen(), color.getBlue(), color.getOpacity());
}