![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=1738887934-k2f1o470zj6N0TGeeQMoK7BjxgqD5O75-0-2508d9c7ab1861f33b84199163716d10)