![Mastering JavaFX 10](https://wfqqreader-1252317822.image.myqcloud.com/cover/811/36699811/b_36699811.jpg)
上QQ阅读APP看书,第一时间看更新
Working with the Shape operations
There are three operations that allow for the combining of two shapes into one:
- Union: Combines two shapes
- Intersect: Leaves only the shared part of two shapes
- Subtract: Removes the shared part from the first shape
These are static methods that can be applied to any two shapes:
Circle circle = new Circle(30);
Rectangle rect = new Rectangle(45, 45);
root.getChildren().addAll(
Shape.union(circle, rect),
Shape.intersect(circle, rect),
Shape.subtract(circle, rect));
The output is as follows:
![](https://epubservercos.yuewen.com/0A344C/19470392808882006/epubprivate/OEBPS/Images/Chapter_94.jpg?sign=1739299731-ayIYQXhaNGW9Q3PMwMbCV49aAnZPIWPg-0-4f56164a6545f80c2091b6756c180891)