JavaFX Gradient Color
In Computer Graphics, Gradient Colors (sometimes called Color Progression ) are used to specify the position dependent colors to fill a particular region. The value of the gradient color varies with the position. Gradient colors produces the smooth color transitions on the region by varying the color value continuously with the position.
JavaFX enables us to implement two types of Gradient color transitions:
To apply linear gradient patterns to the shapes, we need to instantiate the LinearGradient class. This class contains several instance methods described below in the table.
The Constructor of this class accepts five parameters:
new LinearGradient(startX, startY, endX, endY, Proportional, CycleMethod, stops)
(startX,startY): represents x and y coordinates of the starting point of the gradient color.
(endX,endY): represents x and y coordinates of the ending point of the gradient color.
Proportional: This is a boolean type property. If this is true then the starting and ending point of the gradient color will become proportional.
CycleMethod: This defines the cycle method applied to the gradient.
Stops: this defines the color distribution along the gradient.
To apply Radial gradient to the shapes , we need to instantiate javafx.scene.paint.RadialGradient class. This class contains various instance methods described in the table below.
The constructor of the class accepts a few parameters. The Syntax of the constructor is given below.