-
-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CairoMakie
: polygon with hole example not working
#2456
Comments
This polygon works in v0.18.3, i.e., with reversed winding of the hole
|
Yes exactly, it's just that I didn't notice before that the winding order was incorrect because earcut doesn't care, on the mesh conversion route. We could check winding order and error or flip the polygons in case it's wrong, not sure what the better option is. |
To me this doesn't look like a correct usage of p = Polygon(
Point2f[(0, 0), (5, 0), (5, 5), (0, 5)],
[Point2f[(1, 1), (1, 4), (4, 4), (4, 1)],
Point2f[(2, 2), (3, 2), (3, 3), (2, 3)],
Point2f[(2.2,2.2), (2.2,2.8), (2.8,2.8), (2.8,2.2)]]
)
poly!(ax, p) Whereas there is a (logically) much simpler way of doing things: p1 = Polygon(
Point2f[(0, 0), (5, 0), (5, 5), (0, 5)],
[Point2f[(1, 1), (1, 4), (4, 4), (4, 1)]]
)
poly!(ax, p1)
p2 = Polygon(
Point2f[(2, 2), (3, 2), (3, 3), (2, 3)],
[Point2f[(2.2,2.2), (2.2,2.8), (2.8,2.8), (2.8,2.2)]]
)
poly!(ax, p2) |
Is there anything mentioned about winding order in the docs? To me the signature |
If we were to define its usage like that, then there would be no confusion about winding order. |
The reason the nested polygon works in CairoMakie, is that the outlines are just drawn as a multi-segment path, and then filling is determined via the even-odd rule. But I would also argue that this is not canonical polygon behavior. I concur with Florian's opinion that we are talking about one exterior and multiple interior holes. In order to match CairoMakie and GLMakie we should just clearly define somewhere what data we expect, so far it has been to loosely defined. We can probably use whatever definitions the leading GIS packages use, as they probably have the most experience with polygons. |
Sorry for my confusion, I agree my example is malformed
|
The fill rule seems to be
gives
With |
The docs have been fixed and I think the Polygon discussion is something for GeometryBasics instead... Can this be closed? |
IMO this is still something we have to figure out in CairoMakie - whether it should respect this kind of "malformed polygon" or somehow try and correct it before plotting (either assert winding order for the rings, or change the fill rule). The correct GIS thing in this case would be a MultiPolygon that can contain the inner filled rectangle as the second polygon. |
See the 2nd example at the docs page: https://docs.makie.org/v0.18.3/examples/plotting_functions/poly/index.html
Expected output:

The text was updated successfully, but these errors were encountered: