本文整理汇总了Java中javafx.scene.paint.Color.hsb方法的典型用法代码示例。如果您正苦于以下问题:Java Color.hsb方法的具体用法?Java Color.hsb怎么用?Java Color.hsb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.paint.Color
的用法示例。
在下文中一共展示了Color.hsb方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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 };
}
示例3: create3dContent
import javafx.scene.paint.Color; //导入方法依赖的package包/类
public Node create3dContent() {
Xform sceneRoot = new Xform();
cubeXform = new Xform[128];
cube = new Cube[128];
int i;
for (i = 0; i < 128; i++) {
cubeXform[i] = new Xform();
cubeXform[i].setTranslateX((double) 2);
cube[i] = new Cube(1.0, Color.hsb((double) i*1.2, 1.0, 1.0, 0.3), 1.0);
if (i == 0) {
sceneRoot.getChildren().add(cubeXform[i]);
}
else if (i >= 1) {
cubeXform[i-1].getChildren().add(cubeXform[i]);
}
cubeXform[i].getChildren().add(cube[i]);
}
audioSpectrumListener = this;
getAudioMediaPlayer().setAudioSpectrumListener(audioSpectrumListener);
getAudioMediaPlayer().play();
getAudioMediaPlayer().setAudioSpectrumInterval(0.02);
getAudioMediaPlayer().setAudioSpectrumNumBands(128);
getAudioMediaPlayer().setCycleCount(Timeline.INDEFINITE);
sceneRoot.setRotationAxis(Rotate.X_AXIS);
sceneRoot.setRotate(180.0);
sceneRoot.setTranslateY(-100.0);
return sceneRoot;
}
示例4: SimpleHSBColorPicker
import javafx.scene.paint.Color; //导入方法依赖的package包/类
public SimpleHSBColorPicker() {
getChildren().addAll(hsbRect,lightRect);
lightRect.setStroke(Color.GRAY);
lightRect.setStrokeType(StrokeType.OUTSIDE);
EventHandler<MouseEvent> ml = new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent e) {
double w = getWidth();
double h = getHeight();
double x = Math.min(w, Math.max(0, e.getX()));
double y = Math.min(h, Math.max(0, e.getY()));
double hue = (360/w)*x;
double vert = (1/h)*y;
double sat = 0;
double bright = 0;
if (vert<0.5) {
bright = 1;
sat = vert * 2;
} else {
bright = sat = 1- ((vert-0.5)*2);
}
// convert back to color
Color c = Color.hsb((int)hue,sat,bright);
color.set(c);
e.consume();
}
};
lightRect.setOnMouseDragged(ml);
lightRect.setOnMouseClicked(ml);
}
示例5: buildHueBar
import javafx.scene.paint.Color; //导入方法依赖的package包/类
private LinearGradient buildHueBar() {
double offset;
Stop[] stops = new Stop[255];
for (int y = 0; y < 255; y++) {
offset = (double) (1.0 / 255) * y;
int h = (int)((y / 255.0) * 360);
stops[y] = new Stop(offset, Color.hsb(h, 1.0, 1.0));
}
return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
示例6: createIconContent
import javafx.scene.paint.Color; //导入方法依赖的package包/类
public static Node createIconContent() {
double offset;
Stop[] stops = new Stop[255];
for (int y = 0; y < 255; y++) {
offset = (double) (1.0 / 255) * y;
int h = (int)((y / 255.0) * 360);
stops[y] = new Stop(offset, Color.hsb(h, 0.8, 0.9));
}
Rectangle rect = new Rectangle(80,80,
new LinearGradient(0f, 0f, 1f, 1f, true, CycleMethod.NO_CYCLE, stops));
rect.setArcWidth(20);
rect.setArcHeight(20);
return rect;
}
示例7: create3dContent
import javafx.scene.paint.Color; //导入方法依赖的package包/类
@Override public Node create3dContent() {
Xform sceneRoot = new Xform();
cubeXform = new Xform[128];
cube = new Cube[128];
int i;
for (i = 0; i < 128; i++) {
cubeXform[i] = new Xform();
cubeXform[i].setTranslateX((double) 2);
cube[i] = new Cube(1.0, Color.hsb((double) i*1.2, 1.0, 1.0, 0.3), 1.0);
if (i == 0) {
sceneRoot.getChildren().add(cubeXform[i]);
}
else if (i >= 1) {
cubeXform[i-1].getChildren().add(cubeXform[i]);
}
cubeXform[i].getChildren().add(cube[i]);
}
audioSpectrumListener = this;
getAudioMediaPlayer().setAudioSpectrumListener(audioSpectrumListener);
getAudioMediaPlayer().play();
getAudioMediaPlayer().setAudioSpectrumInterval(0.02);
getAudioMediaPlayer().setAudioSpectrumNumBands(128);
getAudioMediaPlayer().setCycleCount(Timeline.INDEFINITE);
sceneRoot.setRotationAxis(Rotate.X_AXIS);
sceneRoot.setRotate(180.0);
sceneRoot.setTranslateY(-100.0);
return sceneRoot;
}
示例8: createHueGradient
import javafx.scene.paint.Color; //导入方法依赖的package包/类
private static LinearGradient createHueGradient() {
double offset;
Stop[] stops = new Stop[255];
for (int x = 0; x < 255; x++) {
offset = 1.0 / 255 * x;
int h = (int) ((x / 255.0) * 360);
stops[x] = new Stop(offset, Color.hsb(h, 1, 1));
}
return new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
}
示例9: createHueGradient
import javafx.scene.paint.Color; //导入方法依赖的package包/类
private static LinearGradient createHueGradient() {
final Stop[] stops = new Stop[255];
for (int x = 0; x < 255; x++) {
final double offset = (1.0 / 255.0) * x;
final int hue = (int)((x / 255.0) * 360);
stops[x] = new Stop(offset, Color.hsb(hue, 1.0, 1.0));
}
return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
示例10: annotate
import javafx.scene.paint.Color; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
if (!isFilterEnabled()) {
return;
}
GL2 gl = drawable.getGL().getGL2();
gl.glPushMatrix();
for (int c=0; c<numCameras; c++){
medianTrackers[c].annotate(drawable);
Float hue= (float) c*360/numCameras; // conversion in hue value, dependindin on the number of cameras
Color color=Color.hsb(hue, 0.5f, 1f);
gl.glColor3d(color.getRed(), color.getGreen(), color.getBlue());
gl.glLineWidth(4);
gl.glBegin(GL2.GL_LINE_LOOP);
Point2D p = medianTrackers[c].getMedianPoint();
Point2D s = medianTrackers[c].getStdPoint();
int sx=chip.getSizeX();
int sy=chip.getSizeY();
gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() - s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() - s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) + s.getX(), p.getY() + s.getY());
gl.glVertex2d((c*sx/numCameras+p.getX()) - s.getX(), p.getY() + s.getY());
gl.glEnd();
}
gl.glPopMatrix();
}
示例11: getComplementaryColor
import javafx.scene.paint.Color; //导入方法依赖的package包/类
public static final Color getComplementaryColor(final Color COLOR) {
return Color.hsb(COLOR.getHue() + 180, COLOR.getSaturation(), COLOR.getBrightness());
}
示例12: 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;
}
示例13: SanFranciscoFireworks
import javafx.scene.paint.Color; //导入方法依赖的package包/类
public SanFranciscoFireworks() {
// create a color palette of 180 colors
colors = new Paint[181];
colors[0] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
new Stop(0, Color.WHITE),
new Stop(0.2, Color.hsb(59, 0.38, 1)),
new Stop(0.6, Color.hsb(59, 0.38, 1,0.1)),
new Stop(1, Color.hsb(59, 0.38, 1,0))
);
for (int h=0;h<360;h+=2) {
colors[1+(h/2)] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
new Stop(0, Color.WHITE),
new Stop(0.2, Color.hsb(h, 1, 1)),
new Stop(0.6, Color.hsb(h, 1, 1,0.1)),
new Stop(1, Color.hsb(h, 1, 1,0))
);
}
// create canvas
canvas = new Canvas(1024, 500);
canvas.setBlendMode(BlendMode.ADD);
canvas.setEffect(new Reflection(0,0.4,0.15,0));
background = new ImageView(getClass().getResource("sf.jpg").toExternalForm());
getChildren().addAll(background,canvas);
// create animation timer that will be called every frame
// final AnimationTimer timer = new AnimationTimer() {
timer = new AnimationTimer() {
@Override public void handle(long now) {
GraphicsContext gc = canvas.getGraphicsContext2D();
// clear area with transparent black
gc.setFill(Color.rgb(0, 0, 0, 0.2));
gc.fillRect(0, 0, 1024, 708);
// draw fireworks
drawFireworks(gc);
// countdown to launching the next firework
if (countDownTillNextFirework == 0) {
countDownTillNextFirework = 10 + (int)(Math.random()*30);
fireParticle();
}
countDownTillNextFirework --;
}
};
}
示例14: getRegionalPaint
import javafx.scene.paint.Color; //导入方法依赖的package包/类
protected static Paint getRegionalPaint(int region)
{
RAND.setSeed(region);
return Color.hsb(RAND.nextInt(360), 0.5, 0.7);
}