Java Reference
In-Depth Information
Listing 7.7
DarkSky
public class DarkSky extends CustomNode {
public var width:Number = 600;
public var height: Number = 600;
def random = Random{};
public override function create(): Node {
return Group {
content: bind [
Rectangle { // Black sky
width: width
height: height
fill: RadialGradient {
centerX: 0.5
centerY: 0.5
stops: [
Stop { offset: 0.0
color:
Color.rgb(128,128,128) },
Stop { offset: 1.0
color: Color.rgb(20,20,20) },
]
}
},
for(i in [0..100]) { // Stars
Circle {
centerX: random.nextInt(
if(width <= 0) 1 else width);
centerY: random.nextInt(
if(height <= 0) 1 else height);
radius: random.nextInt(5);
fill: Color.WHITESMOKE
}
}
]
};
}
}
The Sun is composed of three concentric circles. In the center of the Sun is a pure
white circle. Next, there is a circle with a RadialGradient using a center color
of white transposing to yellow. Both of these circles use a GaussianBlur effect
to blend and smooth the color's edges. The most outer circle is a translucent yel-
low to represent a glare effect around the Sun . Listing 7.8 presents an implemen-
tation for the Sun .
 
Search WWH ::




Custom Search