Java Reference
In-Depth Information
and its angle is not vertical, but to some extent diagonal. A third Stop is included
in the stops sequence, to add gradient transitions from purple to white back to
purple again. Figure 6.11 shows the rendered cone.
Figure 6.11
Adding a LinearGradient to a Compound Shape
Combining all of the snippets together, Listing 6.3 contains the complete set of
code required to generate the image found in Figure 6.11.
Listing 6.3
A Cone with a LinearGradient
import javafx.stage.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
function run(args : String[]) : Void {
Stage {
scene: Scene {
width: 170
height: 220
content: ShapeIntersect {
fill: LinearGradient {
startX: 30, startY: 190
endX: 190, endY: 170
proportional: false
stops: [
Stop {
offset: 0.0
color: Color.PURPLE
},
continues
Search WWH ::




Custom Search