本文整理了Java中javafx.scene.paint.Color.getRed()
方法的一些代码示例,展示了Color.getRed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Color.getRed()
方法的具体详情如下:
包路径:javafx.scene.paint.Color
类名称:Color
方法名:getRed
暂无
代码示例来源:origin: jfoenixadmin/JFoenix
public static String colorToHex(Color c) {
if (c != null) {
return String.format((Locale) null, "#%02x%02x%02x",
Math.round(c.getRed() * 255),
Math.round(c.getGreen() * 255),
Math.round(c.getBlue() * 255)).toUpperCase();
} else {
return null;
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
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+";");
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateHSLCircleColor(int x, int y) {
// transform color to HSL space
Color color = huesCircleView.getImage().getPixelReader().getColor(x, y);
double max = Math.max(color.getRed(), Math.max(color.getGreen(), color.getBlue()));
double min = Math.min(color.getRed(), Math.min(color.getGreen(), color.getBlue()));
double hue = 0;
if (max != min) {
double d = max - min;
if (max == color.getRed()) {
hue = (color.getGreen() - color.getBlue()) / d + (color.getGreen() < color.getBlue() ? 6 : 0);
} else if (max == color.getGreen()) {
hue = (color.getBlue() - color.getRed()) / d + 2;
} else if (max == color.getBlue()) {
hue = (color.getRed() - color.getGreen()) / d + 4;
}
hue /= 6;
}
currentHue = map(hue, 0, 1, 0, 255);
// refresh the HSL circle
refreshHSLCircle();
}
代码示例来源:origin: jfoenixadmin/JFoenix
void createOverlay() {
if (overlayRect == null) {
overlayRect = new OverLayRipple();
overlayRect.setClip(getMask());
getChildren().add(0, overlayRect);
if (ripplerFill.get() instanceof Color) {
overlayRect.setFill(new Color(((Color) ripplerFill.get()).getRed(),
((Color) ripplerFill.get()).getGreen(),
((Color) ripplerFill.get()).getBlue(),
0.2));
}else{
overlayRect.setFill(Color.TRANSPARENT);
}
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
public void moveToColor(Color color) {
allowColorChange = false;
double max = Math.max(color.getRed(),
Math.max(color.getGreen(), color.getBlue())), min = Math.min(color.getRed(),
Math.min(color.getGreen(),
color.getBlue()));
double d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
if (max == color.getRed()) {
hue = (color.getGreen() - color.getBlue()) / d + (color.getGreen() < color.getBlue() ? 6 : 0);
} else if (max == color.getGreen()) {
hue = (color.getBlue() - color.getRed()) / d + 2;
} else if (max == color.getBlue()) {
hue = (color.getRed() - color.getGreen()) / d + 4;
代码示例来源:origin: jfoenixadmin/JFoenix
/**
* {@inheritDoc}
*/
@Override
protected void interpolate(double frac) {
if (start == null) {
starting();
}
Color newColor = start.interpolate(end, frac);
if (Color.TRANSPARENT.equals(start)) {
newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity());
}
region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets)));
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
setScaleY(0);
if (ripplerFill.get() instanceof Color) {
Color circleColor = new Color(((Color) ripplerFill.get()).getRed(),
((Color) ripplerFill.get()).getGreen(),
((Color) ripplerFill.get()).getBlue(),
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateColor() {
final ColorPicker colorPicker = (ColorPicker) getSkinnable();
Color color = colorPicker.getValue();
// update picker box color
Color circleColor = color == null ? Color.WHITE : color;
Circle colorCircle = new Circle();
colorCircle.setFill(circleColor);
colorCircle.setLayoutX(colorBox.getWidth() / 4);
colorCircle.setLayoutY(colorBox.getHeight() / 2);
colorBox.getChildren().add(colorCircle);
Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240),
new KeyValue(colorCircle.radiusProperty(),
200,
Interpolator.EASE_BOTH)));
animateColor.setOnFinished((finish) -> {
JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill());
colorBox.getChildren().remove(colorCircle);
});
animateColor.play();
// update label color
displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
"rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
if (colorLabelVisible.get()) {
displayNode.setText(JFXNodeUtils.colorToHex(circleColor));
} else {
displayNode.setText("");
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
if (concurrencyController.getAndSet(1) == -1) {
Color fontColor = ((Color) newVal.getFills().get(0).getFill()).grayscale()
.getRed() > 0.5 ? Color.valueOf(
"rgba(40, 40, 40, 0.87)") : Color.valueOf("rgba(255, 255, 255, 0.87)");
for (Node tabNode : tabs.lookupAll(".tab")) {
(int) (newColor.getRed() * 255),
(int) (newColor.getGreen() * 255),
(int) (newColor.getBlue() * 255));
String rgb = String.format("rgba(%d, %d, %d, 1)",
(int) (newColor.getRed() * 255),
(int) (newColor.getGreen() * 255),
(int) (newColor.getBlue() * 255));
代码示例来源:origin: com.jfoenix/jfoenix
public static String colorToHex(Color c) {
if (c != null) {
return String.format((Locale) null, "#%02x%02x%02x",
Math.round(c.getRed() * 255),
Math.round(c.getGreen() * 255),
Math.round(c.getBlue() * 255)).toUpperCase();
} else {
return null;
}
}
代码示例来源:origin: com.cedarsoft.commons/javafx
@Nonnull
public static String toRGB(@Nonnull Color color) {
int r = (int) (color.getRed() * 255);
int g = (int) (color.getGreen() * 255);
int b = (int) (color.getBlue() * 255);
return "rgb(" + r + ", " + g + ", " + b + ")";
}
代码示例来源:origin: org.fxmisc.richtext/richtextfx
@Override
public void encode(DataOutputStream os, Color c)
throws IOException {
os.writeDouble(c.getRed());
os.writeDouble(c.getGreen());
os.writeDouble(c.getBlue());
os.writeDouble(c.getOpacity());
}
代码示例来源:origin: com.github.almasb/fxgl-entity
public void set(Color color) {
r = (byte) (255 * color.getRed());
g = (byte) (255 * color.getGreen());
b = (byte) (255 * color.getBlue());
a = (byte) 255;
}
代码示例来源:origin: com.github.almasb/fxgl-physics
public void set(Color color) {
r = (byte) (255 * color.getRed());
g = (byte) (255 * color.getGreen());
b = (byte) (255 * color.getBlue());
a = (byte) 255;
}
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
private Color calculateContrastColor(Color color) {
double r = color.getRed();
double g = color.getGreen();
double b = color.getBlue();
double gray = (r + g + b);
if (gray > 0.7) {
return Color.BLACK;
} else {
return Color.WHITE;
}
}
代码示例来源:origin: com.cedarsoft.commons/javafx
@Nonnull
public static String toRGBA(@Nonnull Color color) {
int r = (int) (color.getRed() * 255);
int g = (int) (color.getGreen() * 255);
int b = (int) (color.getBlue() * 255);
return "rgb(" + r + ", " + g + ", " + b + ", " + color.getOpacity() + ")";
}
代码示例来源:origin: us.ihmc/ihmc-footstep-planning-visualizers
public static Color toTransparentColor(Color opaqueColor, double opacity)
{
double red = opaqueColor.getRed();
double green = opaqueColor.getGreen();
double blue = opaqueColor.getBlue();
return new Color(red, green, blue, opacity);
}
代码示例来源:origin: com.github.peterbecker/configuration-parser
/**
* Method to decode an AWT color encoded the JavaFX/web way.
* <p/>
* AWT has Color::decode, but that needs a full three byte integer value. JavaFX allows all CSS variants, including
* names.
*/
private static Color decodeAwtColor(String s) {
javafx.scene.paint.Color color = javafx.scene.paint.Color.valueOf(s);
return new Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity());
}
代码示例来源:origin: com.jfoenix/jfoenix
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+";");
}
}
代码示例来源:origin: eu.mihosoft.vrl.jcsg/jcsg
public CSG color(Color c) {
CSG result = this.clone();
storage.set("material:color",
"" + c.getRed()
+ " " + c.getGreen()
+ " " + c.getBlue());
return result;
}
内容来源于网络,如有侵权,请联系作者删除!