diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4122ef0eb..21700d21d63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Documented `WilkinsonTicks` [#3819](https://github.com/MakieOrg/Makie.jl/pull/3819). - Added `axislegend(ax, "title")` method [#3808](https://github.com/MakieOrg/Makie.jl/pull/3808). - Improved thread safety of rendering with CairoMakie (independent `Scene`s only) by locking FreeType handles [#3777](https://github.com/MakieOrg/Makie.jl/pull/3777). +- Provided an interface to convert markers in CairoMakie separately (`cairo_scatter_marker`) so external packages can overload it. [#3811](https://github.com/MakieOrg/Makie.jl/pull/3811) +- Updated to DelaunayTriangulation v1.0 [#3787](https://github.com/MakieOrg/Makie.jl/pull/3787). - Added methods `hidedecorations!`, `hiderdecorations!`, `hidethetadecorations!` and `hidespines!` for `PolarAxis` axes [#3823](https://github.com/MakieOrg/Makie.jl/pull/3823). ## [0.20.9] - 2024-03-29 diff --git a/CairoMakie/Project.toml b/CairoMakie/Project.toml index 6ee7208df79..2e8a82ce5bc 100644 --- a/CairoMakie/Project.toml +++ b/CairoMakie/Project.toml @@ -1,13 +1,12 @@ name = "CairoMakie" uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" author = ["Simon Danisch "] -version = "0.11.10" +version = "0.11.11" [deps] CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" -FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" @@ -19,7 +18,6 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" CRC32c = "1.0, 1.6" Cairo = "1.0.4" Colors = "0.10, 0.11, 0.12" -FFTW = "1" FileIO = "1.1" FreeType = "3, 4.0" GeometryBasics = "0.4.1" diff --git a/CairoMakie/src/primitives.jl b/CairoMakie/src/primitives.jl index 1c760e12bb0..b9736a37718 100644 --- a/CairoMakie/src/primitives.jl +++ b/CairoMakie/src/primitives.jl @@ -299,8 +299,8 @@ end ################################################################################ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Scatter)) - @get_attribute(primitive, (markersize, strokecolor, strokewidth, marker, marker_offset, rotations, transform_marker)) - + @get_attribute(primitive, (markersize, strokecolor, strokewidth, marker_offset, rotations, transform_marker)) + marker = cairo_scatter_marker(primitive.marker[]) # this goes through CairoMakie's conversion system and not Makie's... ctx = screen.context model = primitive.model[] positions = primitive[1][] @@ -1093,6 +1093,7 @@ end function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Makie.MeshScatter)) @get_attribute(primitive, (model, marker, markersize, rotations)) + pos = primitive[1][] # For correct z-ordering we need to be in view/camera or screen space model = copy(model) diff --git a/CairoMakie/src/utils.jl b/CairoMakie/src/utils.jl index 12d0f9ae981..f0c8806e6da 100644 --- a/CairoMakie/src/utils.jl +++ b/CairoMakie/src/utils.jl @@ -154,6 +154,19 @@ function set_source(ctx::Cairo.CairoContext, color::Colorant) return Cairo.set_source_rgba(ctx, rgbatuple(color)...) end +######################################## +# Marker conversion API # +######################################## + +""" + cairo_scatter_marker(marker) + +Convert a Makie marker to a Cairo-compatible marker. This defaults to calling +`Makie.to_spritemarker`, but can be overridden for specific markers that can +be directly rendered to vector formats using Cairo. +""" +cairo_scatter_marker(marker) = Makie.to_spritemarker(marker) + ######################################## # Image/heatmap -> ARGBSurface # ######################################## diff --git a/Project.toml b/Project.toml index fd1c655b0e2..dfd9869503c 100644 --- a/Project.toml +++ b/Project.toml @@ -67,7 +67,7 @@ ColorSchemes = "3.5" ColorTypes = "0.8, 0.9, 0.10, 0.11" Colors = "0.9, 0.10, 0.11, 0.12" Contour = "0.5, 0.6" -DelaunayTriangulation = "0.8.7" +DelaunayTriangulation = "1.0" Distributions = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" DocStringExtensions = "0.8, 0.9" Downloads = "1, 1.6" diff --git a/ReferenceTests/src/tests/examples2d.jl b/ReferenceTests/src/tests/examples2d.jl index 2bedc371f4b..ce53a5ddbd4 100644 --- a/ReferenceTests/src/tests/examples2d.jl +++ b/ReferenceTests/src/tests/examples2d.jl @@ -767,8 +767,8 @@ end boundary_nodes, points = convert_boundary_points_to_indices(curves; existing_points=points) edges = Set(((1, 19), (19, 12), (46, 4), (45, 12))) - tri = triangulate(points; boundary_nodes = boundary_nodes, edges = edges, check_arguments = false) - z = [(x - 1) * (y + 1) for (x, y) in each_point(tri)] + tri = triangulate(points; boundary_nodes = boundary_nodes, segments = edges, check_arguments = false) + z = [(x - 1) * (y + 1) for (x, y) in DelaunayTriangulation.each_point(tri)] f, ax, _ = tricontourf(tri, z, levels = 30) f end @@ -783,7 +783,7 @@ end end boundary_nodes, points = convert_boundary_points_to_indices(xy) tri = triangulate(points; boundary_nodes=boundary_nodes, check_arguments=false) - z = [(x - 3/2)^2 + y^2 for (x, y) in each_point(tri)] + z = [(x - 3/2)^2 + y^2 for (x, y) in DelaunayTriangulation.each_point(tri)] f, ax, tr = tricontourf(tri, z, colormap = :matter) f @@ -1316,7 +1316,7 @@ end @reference_test "Voronoiplot for a tessellation with a custom bounding box" begin pts = 25RNG.randn(2, 50) tri = triangulate(pts; rng = RNG.STABLE_RNG) - vorn = voronoi(tri, false) + vorn = voronoi(tri, clip = false) fig, ax, sc = voronoiplot(vorn, show_generators=true, colormap=:RdBu, @@ -1334,7 +1334,7 @@ end @reference_test "Voronoiplots with clipped tessellation and unbounded polygons" begin pts = 25RNG.randn(2, 10) tri = triangulate(pts; rng = RNG.STABLE_RNG) - vorn = voronoi(tri, true) + vorn = voronoi(tri, clip = true) fig, ax, sc = voronoiplot(vorn, color = (:blue,0.2), markersize = 20, strokewidth = 4) # used to be bugged diff --git a/ReferenceTests/src/tests/primitives.jl b/ReferenceTests/src/tests/primitives.jl index d59149c3822..0b2a15d2233 100644 --- a/ReferenceTests/src/tests/primitives.jl +++ b/ReferenceTests/src/tests/primitives.jl @@ -311,7 +311,7 @@ end circle_with_hole = BezierPath([ MoveTo(Point(1, 0)), - EllipticalArc(Point(0, 0), 1, 1, 0, 0, 2pi), + Makie.EllipticalArc(Point(0, 0), 1, 1, 0, 0, 2pi), MoveTo(Point(0.5, 0.5)), LineTo(Point(0.5, -0.5)), LineTo(Point(-0.5, -0.5)), @@ -330,16 +330,16 @@ end two_circles_with_holes = Makie.scale(BezierPath([ MoveTo(Point(2.25, 0)), - EllipticalArc(Point(1.25, 0), 1, 1, 0, 0, 2pi), + Makie.EllipticalArc(Point(1.25, 0), 1, 1, 0, 0, 2pi), ClosePath(), MoveTo(Point(-0.25, 0)), - EllipticalArc(Point(-1.25, 0), 1, 1, 0, 0, 2pi), + Makie.EllipticalArc(Point(-1.25, 0), 1, 1, 0, 0, 2pi), ClosePath(), MoveTo(Point(2, 0)), - EllipticalArc(Point(1.25, 0), 0.75, 0.75, 0, 0, -2pi), + Makie.EllipticalArc(Point(1.25, 0), 0.75, 0.75, 0, 0, -2pi), ClosePath(), MoveTo(Point(-1, 0)), - EllipticalArc(Point(-1.25, 0), 0.25, 0.25, 0, 0, -2pi), + Makie.EllipticalArc(Point(-1.25, 0), 0.25, 0.25, 0, 0, -2pi), ClosePath(), ]), 0.5) diff --git a/docs/reference/plots/tricontourf.md b/docs/reference/plots/tricontourf.md index abc18e24168..6ac11846209 100644 --- a/docs/reference/plots/tricontourf.md +++ b/docs/reference/plots/tricontourf.md @@ -145,8 +145,8 @@ boundary_nodes, points = convert_boundary_points_to_indices(curves; existing_poi edges = Set(((1, 19), (19, 12), (46, 4), (45, 12))) ## Extract the x, y -tri = triangulate(points; boundary_nodes = boundary_nodes, edges = edges, check_arguments = false) -z = [(x - 1) * (y + 1) for (x, y) in each_point(tri)] # note that each_point preserves the index order +tri = triangulate(points; boundary_nodes = boundary_nodes, segments = edges) +z = [(x - 1) * (y + 1) for (x, y) in DelaunayTriangulation.each_point(tri)] # note that each_point preserves the index order f, ax, _ = tricontourf(tri, z, levels = 30; axis = (; aspect = 1)) f ``` @@ -169,8 +169,8 @@ for i in 1:2 push!(xy, [[(cx[i] + 0.5cos(θ), 0.5sin(θ)) for θ in reverse(θ)]]) end boundary_nodes, points = convert_boundary_points_to_indices(xy) -tri = triangulate(points; boundary_nodes=boundary_nodes, check_arguments=false) -z = [(x - 3/2)^2 + y^2 for (x, y) in each_point(tri)] # note that each_point preserves the index order +tri = triangulate(points; boundary_nodes=boundary_nodes) +z = [(x - 3/2)^2 + y^2 for (x, y) in DelaunayTriangulation.each_point(tri)] # note that each_point preserves the index order f, ax, tr = tricontourf(tri, z, colormap = :matter) f diff --git a/docs/reference/plots/triplot.md b/docs/reference/plots/triplot.md index 0fed4ccd0cf..731f88b725f 100644 --- a/docs/reference/plots/triplot.md +++ b/docs/reference/plots/triplot.md @@ -72,9 +72,9 @@ inner = [ boundary_points = [[outer], [inner]] boundary_nodes, points = convert_boundary_points_to_indices(boundary_points) tri = triangulate(points; boundary_nodes = boundary_nodes) -refine!(tri; max_area=1e-3get_total_area(tri)) +refine!(tri; max_area=1e-3*get_area(tri)) f, ax, tr = triplot(tri, show_constrained_edges = true, constrained_edge_linewidth = 4, show_convex_hull = true) f ``` -\end{examplefigure} \ No newline at end of file +\end{examplefigure} diff --git a/docs/reference/plots/voronoiplot.md b/docs/reference/plots/voronoiplot.md index f957a2973bb..1659413a092 100644 --- a/docs/reference/plots/voronoiplot.md +++ b/docs/reference/plots/voronoiplot.md @@ -100,7 +100,7 @@ Random.seed!(1234) points = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)] tri = triangulate(points) refine!(tri; max_area = 0.001) -vorn = voronoi(tri, true) +vorn = voronoi(tri, clip = true) f, ax, tr = voronoiplot(vorn, show_generators = true, markersize = 13, marker = 'x') f ``` @@ -121,7 +121,7 @@ y = sin.(angles) points = tuple.(x, y) tri = triangulate(points) refine!(tri; max_area = 0.001) -vorn = voronoi(tri, true) +vorn = voronoi(tri, clip = true) smooth_vorn = centroidal_smooth(vorn) f, ax, tr = voronoiplot(smooth_vorn, show_generators=false) f diff --git a/src/basic_recipes/tricontourf.jl b/src/basic_recipes/tricontourf.jl index e711345735d..af0be084226 100644 --- a/src/basic_recipes/tricontourf.jl +++ b/src/basic_recipes/tricontourf.jl @@ -67,7 +67,7 @@ function Makie.convert_arguments(::Type{<:Tricontourf}, x::AbstractVector{<:Real end tri = DelTri.Triangulation(points) triangles = DelTri.get_triangles(tri) - for τ in DelTri.each_solid_triangle(triangulation) + for τ in eachcol(triangulation) DelTri.add_triangle!(triangles, τ) end end diff --git a/src/basic_recipes/triplot.jl b/src/basic_recipes/triplot.jl index 917e3ff4265..a74fc37071d 100644 --- a/src/basic_recipes/triplot.jl +++ b/src/basic_recipes/triplot.jl @@ -97,7 +97,7 @@ function get_triangulation_triangles!(triangles, tri) empty!(triangles) sizehint!(triangles, DelTri.num_solid_triangles(tri)) for T in DelTri.each_solid_triangle(tri) - i, j, k = DelTri.indices(T) + i, j, k = DelTri.triangle_vertices(T) push!(triangles, TriangleFace(i, j, k)) end return triangles @@ -114,7 +114,7 @@ function get_triangulation_ghost_edges!(ghost_edges, extent, tri, bounding_box) Val(true)) else xmin, xmax, ymin, ymax = DelTri.polygon_bounds(DelTri.get_points(tri), - DelTri.get_convex_hull_indices(tri), + DelTri.get_convex_hull_vertices(tri), Val(true)) end Δx = xmax - xmin @@ -129,8 +129,8 @@ function get_triangulation_ghost_edges!(ghost_edges, extent, tri, bounding_box) a, b, c, d = map(Float64, (a, b, c, d)) @assert a < b && c < d "Bounding box must be of the form (xmin, xmax, ymin, ymax)." for e in DelTri.each_ghost_edge(tri) - u, v = DelTri.edge_indices(e) - if DelTri.is_boundary_index(v) + u, v = DelTri.edge_vertices(e) + if DelTri.is_ghost_vertex(v) u, v = v, u # Make sure that u is the boundary index end curve_index = DelTri.get_curve_index(tri, u) @@ -151,7 +151,7 @@ function get_triangulation_ghost_edges!(ghost_edges, extent, tri, bounding_box) end function get_triangulation_convex_hull!(convex_hull, tri) - idx = DelTri.get_convex_hull_indices(tri) + idx = DelTri.get_convex_hull_vertices(tri) empty!(convex_hull) sizehint!(convex_hull, length(idx)) for i in idx @@ -164,9 +164,9 @@ end function get_triangulation_constrained_edges!(constrained_edges, tri) empty!(constrained_edges) - sizehint!(constrained_edges, DelTri.num_edges(DelTri.get_all_constrained_edges(tri))) - for e in DelTri.each_constrained_edge(tri) - u, v = DelTri.edge_indices(e) + sizehint!(constrained_edges, DelTri.num_edges(DelTri.get_all_segments(tri))) + for e in DelTri.each_segment(tri) + u, v = DelTri.edge_vertices(e) p = DelTri.get_point(tri, u) q = DelTri.get_point(tri, v) px, py = DelTri.getxy(p) diff --git a/src/makielayout/blocks/colorbar.jl b/src/makielayout/blocks/colorbar.jl index 9032a15a888..ac25b1374f2 100644 --- a/src/makielayout/blocks/colorbar.jl +++ b/src/makielayout/blocks/colorbar.jl @@ -167,7 +167,7 @@ function initialize_block!(cb::Colorbar) if mapping_type === Makie.banded error("Banded without a mapping is invalid. Please use colormap=cgrad(...; categorical=true)") elseif mapping_type === Makie.categorical - return convert(Vector{Float64},1:length(unique(values))) + return convert(Vector{Float64}, sort!(unique(values))) else return convert(Vector{Float64}, LinRange(limits..., n)) end @@ -212,7 +212,7 @@ function initialize_block!(cb::Colorbar) xmin, ymin = minimum(bb) xmax, ymax = maximum(bb) if mapping_type == Makie.categorical - colors = edges(colors) + colors = edges(1:length(colors)) end s_scaled = scale.(colors) mini, maxi = extrema(s_scaled)