- Mastering JavaFX 10
- Sergey Grinev
- 77字
- 2021-06-25 21:21:57
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:
