Java Reference
In-Depth Information
How to do it...
The next code snippet uses ShapeSubtract to create a new shape using constructive area
geometry to form the dome (see the next figure). You can find the full code in ch02/source-
code/src/shapes/ShapeIntersection.fx .
1. First, let's define the shapes that will make up the tip of the dome:
def c1 = Circle {centerX: 175, centerY:28 radius:25}
def c2 = Circle {centerX: 225, centerY:28 radius:25}
def r1 = Rectangle {x:175 y :25 width:50 height:25}
2. Then we define an arc for the bottom of the dome as follows:
def a1 = Arc {
centerX:200
centerY:149
radiusX:100
radiusY:100
startAngle:0 length:180
fill:Color.BISQUE
}
3. Next, we apply the shape operations using the ShapeSubtract .
Scene {
width: w height: h
fill:Color.RED
content:[
ShapeSubtract {a:[r1] b:[c1,c2] fill:Color.BISQUE},
ShapeSubtract{
a:a1
b:[for(i in [0..3]){
Circle {
centerX: 125 + (i*50),
centerY:149 radius:17}
}]
fill:Color.BISQUE
}
]
}
 
Search WWH ::




Custom Search