Java Reference
In-Depth Information
the cycle method is set to the no cycle ( CycleMethod.NO_CYCLE ), and the two
color stop values are set to red ( Color.RED ) and black ( Color.BLACK ). These set-
tings create a radial gradient by starting with the color red at a center position of (80,
45) (upper left of the ellipse) and then interpolating it to the color black with a distance
of 120 pixels (radius).
Next, a rectangle having a yellow semitransparent linear gradient is created. A lin-
ear gradient ( LinearGradient ) paint is used for the yellow rectangle.
Table 14-2 is taken from the JavaFX 8.0 Javadoc definitions found for the Lin-
earGradient class (see http://docs.oracle.com/javase/8/javafx/
api/javafx/scene/paint/LinearGradient.html ).
Table 14-2 . LinearGradient Properties
Property
Data Type
Description
X coordinate of the gradient axis start point
startX
double
Y coordinate of the gradient axis start point
startY
double
X coordinate of the gradient axis end point
endX
double
Y coordinate of the gradient axis end point
endY
double
proportional
boolean
Whether the coordinates are proportional to the shape
that this gradient fills
cycleMethod
CycleMethod
Cycle method applied to the gradient
Whether this paint is completely opaque
opaque
boolean
Gradient's color specification
stops
List<Stop>
To create a linear gradient paint, you specify the startX , startY , endX , and
endY for the start\end points. The start and end point coordinates denote where the
gradient pattern starts and stops.
To create the second shape (yellow rectangle), set the start X and Y to ( 50, 50), the
end X and Y to (50, 75), the proportional to false, the cycle method to no cycle
( CycleMethod.NO_CYCLE ), and the two color stop values to yellow ( Col-
or.YELLOW ) and black ( Color.BLACK ), with an alpha transparency of .784. These
settings provide a linear gradient for the rectangle from top to bottom, with a starting
point of (50, 50) (top-left of the rectangle). It then interpolates to the color black
(bottom-left of the rectangle).
Finally, you'll notice a rounded rectangle with a repeating pattern of a gradient us-
ing green and black in a diagonal direction. This is a simple linear gradient paint that is
 
 
Search WWH ::




Custom Search