Skip to content
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

reverse interior for Cairo hole drawing #2918

Merged
merged 4 commits into from May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions CairoMakie/src/overrides.jl
Expand Up @@ -66,7 +66,6 @@ end

draw_poly(scene::Scene, screen::Screen, poly, rect::Rect2) = draw_poly(scene, screen, poly, [rect])


function draw_poly(scene::Scene, screen::Screen, poly, rects::Vector{<:Rect2})
model = poly.model[]
space = to_value(get(poly, :space, :data))
Expand All @@ -87,16 +86,19 @@ end

function polypath(ctx, polygon)
ext = decompose(Point2f, polygon.exterior)
Cairo.set_fill_type(ctx, Cairo.CAIRO_FILL_RULE_EVEN_ODD)
Cairo.move_to(ctx, ext[1]...)
for point in ext[2:end]
Cairo.line_to(ctx, point...)
end
Cairo.close_path(ctx)

interiors = decompose.(Point2f, polygon.interiors)
for interior in interiors
# Cairo needs to have interiors counter clockwise
n = length(interior)
Cairo.move_to(ctx, interior[1]...)
for point in interior[2:end]
for idx in 2:n
point = interior[idx]
Cairo.line_to(ctx, point...)
end
Cairo.close_path(ctx)
Expand Down