Skip to content

Commit

Permalink
Release v0.20.10 (#3814)
Browse files Browse the repository at this point in the history
* Upgrade to DelaunayTriangulation v1.0 (#3787)

* Upgrade to DelaunayTriangulation v1.0

* Updates for DelaunayTriangulation v1.0

* changelog

* Allow Cairo scatter marker conversion to be overridden (#3811)

* Define cairo_scatter_marker api

* Bump CairoMakie version

* Implement cairo_scatter_marker API for scatter and meshscatter

* Add to changelog

* MeshScatter conversion is different, don't implement

* fix ticks for categorical colorbar (#3762)

* Update tricontourf.md in 0.20.10 branch (#3828)

Update tricontourf.md

* fix docs

---------

Co-authored-by: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com>
Co-authored-by: Simon <sdanisch@protonmail.com>
  • Loading branch information
3 people committed May 6, 2024
1 parent e7a6393 commit 028ccb6
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 35 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions CairoMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name = "CairoMakie"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
author = ["Simon Danisch <sdanisch@gmail.com>"]
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"
Expand All @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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][]
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions CairoMakie/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
########################################
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions ReferenceTests/src/tests/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions docs/reference/plots/tricontourf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/plots/triplot.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
\end{examplefigure}
4 changes: 2 additions & 2 deletions docs/reference/plots/voronoiplot.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/basic_recipes/tricontourf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/basic_recipes/triplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/blocks/colorbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 028ccb6

Please sign in to comment.