Skip to content

Commit

Permalink
Fix poly Circle & Rect stroke (#4664)
Browse files Browse the repository at this point in the history
* fix discontinuous Rect2 stroke and wireframe-like CIrcle stroke

* extend poly refimg test

* fix test (axis background poly now uses lines, so +2 shaders)

* switch to heatmap to generate more shaders

* Update CHANGELOG.md
  • Loading branch information
ffreyer authored Dec 16, 2024
1 parent 5c7aafa commit f29e93a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Added `transform_marker` attribute to meshscatter and changed the default behavior to not transform marker/mesh vertices [#4606](https://github.com/MakieOrg/Makie.jl/pull/4606)
- Fixed some issues with meshscatter not correctly transforming with transform functions and float32 rescaling [#4606](https://github.com/MakieOrg/Makie.jl/pull/4606)
- Fixed `poly` pipeline for 3D and/or Float64 polygons that begin from an empty vector [#4615](https://github.com/MakieOrg/Makie.jl/pull/4615).
- Fixed gaps in corners of `poly(Rect2(...))` stroke [#4664](https://github.com/MakieOrg/Makie.jl/pull/4664)
- Fixed an issue where `reinterpret`ed arrays of line points were not handled correctly in CairoMakie [#4668](https://github.com/MakieOrg/Makie.jl/pull/4668).

## [0.21.18] - 2024-12-12
Expand Down
34 changes: 17 additions & 17 deletions GLMakie/test/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ end
@testset "shader cache" begin
GLMakie.closeall()
screen = display(GLMakie.Screen(visible = false), Figure())
cache = screen.shader_cache
cache = screen.shader_cache;
# Postprocessing shaders
@test length(cache.shader_cache) == 5
@test length(cache.template_cache) == 5
@test length(cache.program_cache) == 4

# Shaders for scatter + linesegments + poly etc (axis)
display(screen, scatter(1:4))
@test length(cache.shader_cache) == 16
@test length(cache.template_cache) == 16
@test length(cache.program_cache) == 10
@test length(cache.shader_cache) == 18
@test length(cache.template_cache) == 18
@test length(cache.program_cache) == 11

# No new shaders should be added:
display(screen, scatter(1:4))
@test length(cache.shader_cache) == 16
@test length(cache.template_cache) == 16
@test length(cache.program_cache) == 10
@test length(cache.shader_cache) == 18
@test length(cache.template_cache) == 18
@test length(cache.program_cache) == 11

# Same for linesegments
display(screen, linesegments(1:4))
@test length(cache.shader_cache) == 16
@test length(cache.template_cache) == 16
@test length(cache.program_cache) == 10

# Lines hasn't been compiled so one new program should be added
display(screen, lines(1:4))
@test length(cache.shader_cache) == 18
@test length(cache.template_cache) == 18
@test length(cache.program_cache) == 11

# heatmap hasn't been compiled so one new program should be added
display(screen, heatmap([1,2,2.5,3], [1,2,2.5,3], rand(4,4)))
@test length(cache.shader_cache) == 20
@test length(cache.template_cache) == 20
@test length(cache.program_cache) == 12

# For second time no new shaders should be added
display(screen, lines(1:4))
@test length(cache.shader_cache) == 18
@test length(cache.template_cache) == 18
@test length(cache.program_cache) == 11
display(screen, heatmap([1,2,2.5,3], [1,2,2.5,3], rand(4,4)))
@test length(cache.shader_cache) == 20
@test length(cache.template_cache) == 20
@test length(cache.program_cache) == 12
end

@testset "unit tests" begin
Expand Down
6 changes: 6 additions & 0 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ end
linesegments!(ax,
[Point2f(50 + i, 50 + i) => Point2f(i + 70, i + 70) for i = 1:100:400], linewidth=8, color=:purple
)
poly!(ax, [Polygon(decompose(Point2f, Rect2f(150, 0, 100, 100))), Polygon(decompose(Point2f, Circle(Point2f(350, 200), 50)))],
color=:gray, strokewidth=10, strokecolor=:red)
# single objects
poly!(ax, Circle(Point2f(50, 350), 50), color=:gray, strokewidth=10, strokecolor=:red)
poly!(ax, Rect2f(0, 150, 100, 100), color=:gray, strokewidth=10, strokecolor=:red)
poly!(ax, Polygon(decompose(Point2f, Rect2f(150, 300, 100, 100))), color=:gray, strokewidth=10, strokecolor=:red)
fig
end

Expand Down
2 changes: 1 addition & 1 deletion src/basic_recipes/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function to_lines(polygon::AbstractVector{<: VecTypes})
return result
end

function plot!(plot::Poly{<: Tuple{<: Union{Polygon, MultiPolygon, AbstractVector{<: PolyElements}}}})
function plot!(plot::Poly{<: Tuple{<: Union{Polygon, MultiPolygon, Rect2, Circle, AbstractVector{<: PolyElements}}}})
geometries = plot[1]
transform_func = plot.transformation.transform_func
meshes = lift(poly_convert, plot, geometries, transform_func)
Expand Down

0 comments on commit f29e93a

Please sign in to comment.