Reputation: 65
My JavaFX application draws up to 10 different types of shapes. Some of them are complex and must be drawn with Path as a series of lines and arcs. Some of the shapes are negative areas where they are to be subtracted from any shapes they overlap.
I've found that subtracting from basic Javafx shapes such as Circle and Rectangle work as expected but shapes made from Path do not.
The overlapped shape shown:
The result of subtracting:
As you can see the shape is subtracted from the circle correctly but attempting to subtract the ellipse from the "fillet" shape only leaves a gap and the lines are darker/thicker because it is trying to close that gap by retracing back around to the other end of the gap instead of drawing the overlapped area.
Here's the code for drawing the complex shape shown in the image
//Here the v shape is drawn from right to left
Path path = new Path();
path.getElements().add(new MoveTo(firstLineXposition, firstLineYposition));
path.getElements().add(new LineTo(originX, originY));
path.getElements().add(new LineTo(secondLineXPos, secondLineYPos));
//here the arc is drawn from top left point to the top right point
ArcTo arc = new ArcTo();
arc.setX(firstLineXposition);
arc.setY(firstLineYposition);
arc.setRadiusX(radiusPositionX);
arc.setRadiusY(radiusPositionY);
path.getElements().add(arc);
path.getElements().add(new ClosePath());
I'm guessing that there is a missed step in drawing these shapes with Path, it should be treated as one whole shape and appears to be treated as a series of lines instead.
Upvotes: 2
Views: 376
Reputation: 10650
I assume your Path is not filled (has no fill color set). So I guess you are just intersecting with the area that is defined by the outline stroke.
Upvotes: 5