The executed code renders the shape shown in the following figure:
How it works...
When you combine different basic shapes, you can create completely new ones. In this
recipe, we used constructive geometry to create the dome in the previous figure. Let's
see how it was constructed:
F Building Blocks —in the code, we declare a series of basic shapes that will be used
to construct the dome. We have circles c1 and c2 , rectangle r1 , and arc a1 .
F Creating the tip of the dome —the shape we are looking for can be formed by
adjoining two circles ( c1 and c2 ) without overlapping. The pointy area between the
two circles is what we are interested in as shown in the next figure (A). The dome's
top is created in two steps:
First, we create a shape to serve as a mask to provide the non-
overlapping area between the two circles. In our example, we create
a small rectangle ( r1 ) that overlaps the area between the circles as
shown in the next figure (B).
Next, we apply the Boolean expression r1 NOT (c1 AND c2) to
create the shape needed. We use an instance of ShapeSubtract
where property a = r1 and property b = [c1,c2] . This produces
the curvy tip shape as shown in the next figure (C).
F Shaping the base of the dome —the dome rendered by the code shows four
semi-circle cutouts at the base of the dome. This is accomplished by dynamically
drawing four circles that are subtracted from arc a1 . Here again, we use the
ShapeSubtract class with property a = a1 and property b = [Circle1,