Java examples for JavaFX:Color
Property | Data Type | Description |
---|---|---|
focusAngle | double | Angle in degrees from the center of the gradient to the focus point to which the first color is mapped |
focusDistance | double | Distance from the center of the gradient to the focus point to which the first color is mapped |
centerX | double | X coordinate of the center point of the gradient's circle |
centerY | double | Y coordinate of the center point of the gradient's circle |
Radius | double | Radius of the circle defining the extents of the color gradient |
Proportional | boolean | Coordinates and sizes are proportional to the shape that this gradient fills |
cycleMethod | CycleMethod | Cycle method applied to the gradient |
opaque stops | boolean List<Stop> | Whether the paint is completely opaque Gradient's color specification |
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.RadialGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Ellipse; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { Application.launch(args);/* w ww .j a v a2 s . c om*/ } @Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 306, 550, Color.WHITE); Ellipse ellipse = new Ellipse(100, 50 + 70/2, 50, 70/2); RadialGradient gradient1 = new RadialGradient(0, .1, // focus angle 80, // focus distance 45, // centerX 120, // centerY false, // proportional CycleMethod.NO_CYCLE, new Stop(0, Color.RED), new Stop(1, Color.BLACK)); ellipse.setFill(gradient1); root.getChildren().add(ellipse); primaryStage.setScene(scene); primaryStage.show(); } }