本文整理汇总了Java中javafx.scene.paint.RadialGradient类的典型用法代码示例。如果您正苦于以下问题:Java RadialGradient类的具体用法?Java RadialGradient怎么用?Java RadialGradient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RadialGradient类属于javafx.scene.paint包,在下文中一共展示了RadialGradient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RadialGradientSample
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public RadialGradientSample() {
//create simple radial gradient
RadialGradient gradient1 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] {
new Stop(0, Color.DODGERBLUE),
new Stop(1, Color.BLACK)
});
Circle circle1 = new Circle(45, 45, 40, gradient1);
//create complex radial gradient
RadialGradient gradient2 = new RadialGradient(20, 1, 0.5, 0.5, 0.6, true, CycleMethod.NO_CYCLE, new Stop[] {
new Stop(0, Color.TRANSPARENT),
new Stop(0.5, Color.DARKGRAY),
new Stop(0.64, Color.WHITESMOKE),
new Stop(0.65, Color.YELLOW),
new Stop(1, Color.GOLD)
});
Circle circle2 = new Circle(145, 45, 40, gradient2);
HBox hb = new HBox(10);
hb.getChildren().addAll(circle1, circle2);
// show the circles
getChildren().addAll(hb);
}
示例2: draw
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
private void draw(final int LIMIT, final double RESOLUTION) {
int limit = LIMIT > points.size() ? points.size() : LIMIT + 1;
double pixelSize = 2 * RESOLUTION;
ctx.clearRect(0, 0, width, height);
for (double y = 0 ; y < height ; y += RESOLUTION) {
for (double x = 0 ; x < width ; x += RESOLUTION) {
double value = getValueAt(limit, x, y);
if (value != -255) {
Color color = getUseColorMapping() ? getColorForValue(value) : getColorForValue(value, isDiscreteColors());
RadialGradient gradient = new RadialGradient(0, 0, x, y, RESOLUTION,
false, CycleMethod.NO_CYCLE,
new Stop(0, Color.color(color.getRed(), color.getGreen(), color.getBlue(), getHeatMapOpacity())),
new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), 0.0)));
ctx.setFill(gradient);
ctx.fillOval(x - RESOLUTION, y - RESOLUTION, pixelSize, pixelSize);
}
}
}
}
示例3: Bullet
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
/**
* The constructor for a bullet.
*
* @param radius - the radius of the bullet
* @param fill - the color of the bullet highlight
*/
public Bullet(double radius, Color fill) {
sphere = CircleBuilder.create()
.centerX(radius)
.centerY(radius)
.radius(radius)
.cache(true)
.build();
RadialGradient rgrad = RadialGradientBuilder.create()
.centerX(sphere.getCenterX() - sphere.getRadius() / 3)
.centerY(sphere.getCenterY() - sphere.getRadius() / 3)
.radius(sphere.getRadius())
.proportional(false)
.stops(new Stop(0.0, fill), new Stop(1.0, Settings.BULLET_PRIMARY_COLOR))
.build();
sphere.setFill(rgrad);
}
示例4: getTasks
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public List<Function<String, Paint>> getTasks() {
return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
text -> Color.web(text, 1),
text -> LinearGradient.valueOf(text),
text -> RadialGradient.valueOf(text),
text -> context.lookup(text),
text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
));
}
示例5: Player
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
/**
* Constructor without cards
* @param name the name of the player
* @param role the role of the player
*/
public Player(String name, Role role) {
this.name = name;
this.role = role;
color = role.roleToColor();
hand = new LinkedList<>();
handDeck = null;
pane = new Pane();
pane.setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0,1,1,.25)), new Stop(1, color.deriveColor(0,1,.5,.25))), new CornerRadii(5), new Insets(0))));
Label description = new Label(role.roleToDescription());
description.setTextFill(role.roleToColor().brighter());
pane.getChildren().add(description);
nameLabel = new Label(name);
nameLabel.setTextFill(role.roleToColor().brighter());
nameLabel.setLayoutX(350);
nameLabel.setLayoutY(20);
pane.getChildren().add(nameLabel);
pawn = new Pawn(this);
}
示例6: createAlphaMaskedBall
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
/**
* Create an alpha masked ball with gradient colors from White to Black/Transparent. Used e. g. for particles.
* May only be visible when you have a background other than white, ie use black
*
* @param radius
* @return
*/
public static Node createAlphaMaskedBall( double radius) {
Circle ball = new Circle(radius);
RadialGradient gradient1 = new RadialGradient(0,
.1,
0,
0,
radius,
false,
CycleMethod.NO_CYCLE,
new Stop(0, Color.WHITE.deriveColor(1,1,1,1)),
new Stop(1, Color.BLACK.deriveColor(1,1,1,0)));
ball.setFill(gradient1);
return ball;
}
示例7: drawLeftImage
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
protected void drawLeftImage() {
AnchorPane pane = new AnchorPane();
pane.setPrefWidth(187);
Stop[] stops = new Stop[] { new Stop(0, Color.web("#3c79b2")), new Stop(1, Color.web("#2d5d8b")) };
RadialGradient gradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, stops);
Background background = new Background(new BackgroundFill(gradient, null, null));
pane.setBackground(background);
Text text = new Text(this.parent.getLeftImageText());
text.setFill(Color.WHITE);
text.setFont(Font.font("Maven Pro", 50));
text.setRotate(-90);
pane.setPadding(new Insets(-50));
pane.getChildren().add(text);
AnchorPane.setBottomAnchor(text, 160.0);
AnchorPane.setRightAnchor(text, -40.0);
getParent().getRoot().setLeft(pane);
}
示例8: fillAquariumBackground
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
/**
* Draws the background of the aquarium.
*/
private void fillAquariumBackground() {
RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
gradientBuilder.centerX(getWorldCanvas().getWidth() / 2);
gradientBuilder.centerY(50);
gradientBuilder.radius(1000);
gradientBuilder.proportional(false);
gradientBuilder.stops(new Stop(0.0, Color.WHITE), new Stop(0.05, Color.rgb(245, 251, 251)),
new Stop(0.1, Color.rgb(220, 242, 239)), new Stop(0.2, Color.rgb(164, 214, 211)),
new Stop(0.3, Color.rgb(142, 195, 199)), new Stop(0.4, Color.rgb(111, 170, 184)),
new Stop(0.5, Color.rgb(84, 145, 166)), new Stop(0.6, Color.rgb(61, 125, 152)),
new Stop(0.7, Color.rgb(50, 111, 140)), new Stop(0.8, Color.rgb(33, 96, 129)),
new Stop(0.9, Color.rgb(25, 85, 121)), new Stop(1.0, Color.rgb(19, 77, 115)));
RadialGradient gradient = gradientBuilder.build();
getWorldCanvas().setFill(gradient);
}
示例9: createBubbleCircle
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
private Circle createBubbleCircle(double radius) {
CircleBuilder<?> circleBuilder = CircleBuilder.create();
circleBuilder.radius(radius);
circleBuilder.cache(true);
Circle sphere = circleBuilder.build();
sphere.setOpacity(BUBBLE_OPACITY);
RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
gradientBuilder.centerX(sphere.getCenterX() - sphere.getRadius() / 3);
gradientBuilder.centerY(sphere.getCenterY() - sphere.getRadius() / 3);
gradientBuilder.radius(sphere.getRadius());
gradientBuilder.proportional(false);
gradientBuilder.stops(new Stop(0.0, Color.BLUE), new Stop(1.0, Color.BLACK));
RadialGradient gradient = gradientBuilder.build();
sphere.setFill(gradient);
return sphere;
}
示例10: addMenuItem
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public void addMenuItem(final String iconPath,
final EventHandler<MouseEvent> eventHandler) {
final RadialGradient backGradient = new RadialGradient(0, 0, 0, 0,
radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0,
BACK_GRADIENT_COLOR), new Stop(1, Color.TRANSPARENT));
final RadialGradient backSelectGradient = new RadialGradient(0, 0, 0,
0, radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0,
BACK_SELECT_GRADIENT_COLOR), new Stop(1,
Color.TRANSPARENT));
final RadialMenuItem item = RadialMenuItemBuilder.create()
.length(length).graphic(new Group(getImageView(iconPath)))
.backgroundFill(backGradient)
.backgroundMouseOnFill(backSelectGradient)
.innerRadius(innerRadius).radius(radius).offset(offset)
.clockwise(true).backgroundVisible(true).strokeVisible(false)
.build();
item.setOnMouseClicked(eventHandler);
items.add(item);
itemsContainer.getChildren().addAll(item);
}
示例11: createIconContent
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public static Node createIconContent() {
Rectangle rect = new Rectangle(80,80,new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] {
new Stop(0, Color.rgb(156,216,255)),
new Stop(0.5, Color.DODGERBLUE),
new Stop(1, Color.rgb(0,70,140))
}));
rect.setArcWidth(20);
rect.setArcHeight(20);
return rect;
}
示例12: init
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
@Override public void init() {
List<YChartItem> item1 = new ArrayList<>(ELEMENTS);
List<YChartItem> item2 = new ArrayList<>(ELEMENTS);
List<YChartItem> item3 = new ArrayList<>(ELEMENTS);
for (int i = 0 ; i < ELEMENTS ; i++) {
YChartItem dataPoint;
dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i);
item1.add(dataPoint);
dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i);
item2.add(dataPoint);
dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i);
item3.add(dataPoint);
}
series1 = new YSeries(item3, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.25)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(255, 0, 255, 0.75))), Color.TRANSPARENT);
series2 = new YSeries(item1, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 0, 0, 0.25)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(0, 200, 0, 0.75))), Color.TRANSPARENT);
series3 = new YSeries(item2, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.25)), new Stop(0.5, Color.rgb(0, 255, 255, 0.5)), new Stop(1.0, Color.rgb(0, 0, 255, 0.75))), Color.TRANSPARENT);
chart = new YChart(new YPane(series1, series2, series3));
chart.setPrefSize(600, 600);
timeline = new Timeline();
lastTimerCall = System.nanoTime();
timer = new AnimationTimer() {
@Override public void handle(final long now) {
if (now > lastTimerCall + INTERVAL) {
animateData();
long delta = System.nanoTime() - now;
timeline.play();
lastTimerCall = now + delta;
}
}
};
registerListener();
}
示例13: setOverlay
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public void setOverlay(Pane pane) {
overlay.getChildren().clear();
if (pane != null) {
Rectangle fade = new Rectangle(mainView.getScene().getWidth(), mainView.getScene().getHeight());
Stop[] stops = {new Stop(0, new Color(0.9, 0.9, 0.9, 0.9)), new Stop(1, new Color(0.1, 0.1, 0.1, 0.1))};
fade.setFill(new RadialGradient(0, 0, 0.5, 0.5, 1.5, true, CycleMethod.NO_CYCLE, stops));
VBox vCenter = new VBox(pane);
HBox hCenter = new HBox(vCenter);
vCenter.setAlignment(Pos.CENTER);
hCenter.setAlignment(Pos.CENTER);
overlay.getChildren().addAll(fade, hCenter);
}
}
示例14: createBubble
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
private Node[] createBubble(final double SIZE) {
final double CENTER = SIZE * 0.5;
final Node[] NODES = new Node[3];
final Circle MAIN = new Circle(CENTER, CENTER, CENTER);
final Paint MAIN_FILL = new LinearGradient(CENTER, 0.02 * SIZE,
0.50 * SIZE, 0.98 * SIZE,
false, CycleMethod.NO_CYCLE,
new Stop(0.0, Color.TRANSPARENT),
new Stop(0.85, Color.rgb(255, 255, 255, 0.2)),
new Stop(1.0, Color.rgb(255, 255, 255, 0.90)));
MAIN.setFill(MAIN_FILL);
MAIN.setStroke(null);
final Circle FRAME = new Circle(CENTER, CENTER, CENTER);
final Paint FRAME_FILL = new RadialGradient(0, 0,
CENTER, CENTER,
0.48 * SIZE,
false, CycleMethod.NO_CYCLE,
new Stop(0.0, Color.TRANSPARENT),
new Stop(0.92, Color.TRANSPARENT),
new Stop(1.0, Color.rgb(255, 255, 255, 0.5)));
FRAME.setFill(FRAME_FILL);
FRAME.setStroke(null);
final Ellipse HIGHLIGHT = new Ellipse(CENTER, 0.27 * SIZE, 0.38 * SIZE, 0.25 * SIZE);
final Paint HIGHLIGHT_FILL = new LinearGradient(CENTER, 0.04 * SIZE,
CENTER, CENTER,
false, CycleMethod.NO_CYCLE,
new Stop(0.0, Color.rgb(255, 255, 255, 0.7)),
new Stop(1.0, Color.TRANSPARENT));
HIGHLIGHT.setFill(HIGHLIGHT_FILL);
HIGHLIGHT.setStroke(null);
NODES[0] = FRAME;
NODES[1] = MAIN;
NODES[2] = HIGHLIGHT;
return NODES;
}
示例15: FXBallVector
import javafx.scene.paint.RadialGradient; //导入依赖的package包/类
public FXBallVector() {
List<Stop> stops = new ArrayList<>();
stops.add(new Stop(0.2, Color.RED));
stops.add(new Stop(0.8, Color.RED.darker()));
stops.add(new Stop(1.0, Color.RED.darker().darker()));
RadialGradient gradient = new RadialGradient(0, 0, 20, 20, 20, false, CycleMethod.NO_CYCLE, stops);
circle = new Circle(20, 20, 20, gradient);
move();
}