Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/codecov/codecov-…
Browse files Browse the repository at this point in the history
…action-4
  • Loading branch information
SimonDanisch authored Feb 12, 2024
2 parents ec05b4c + f92b260 commit 7f33ba3
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 65 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/enforce_news.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Enforce changelog"
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dangoslen/changelog-enforcer@v3
with:
changeLogPath: 'CHANGELOG.md'
skipLabels: 'skip-changelog'
144 changes: 99 additions & 45 deletions NEWS.md → CHANGELOG.md

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,36 @@ complex and slower to draw than standard paths with single color.
"""
function draw_plot(scene::Scene, screen::Screen, poly::Poly)
# dispatch on input arguments to poly to use smarter drawing methods than
# meshes if possible
return draw_poly(scene, screen, poly, to_value.(poly.args)...)
# meshes if possible.
# however, since recipes exist, we can't explicitly handle all cases here
# so, we should also take a look at converted
# First, we check whether a `draw_poly` method exists for the input arguments
# before conversion:
return if Base.hasmethod(draw_poly, Tuple{Scene, Screen, typeof(poly), typeof.(to_value.(poly.args))...})
draw_poly(scene, screen, poly, to_value.(poly.args)...)
# If not, we check whether a `draw_poly` method exists for the arguments after conversion
# (`plot.converted`). This allows anything which decomposes to be checked for.
elseif Base.hasmethod(draw_poly, Tuple{Scene, Screen, typeof(poly), typeof.(to_value.(poly.converted))...})
draw_poly(scene, screen, poly, to_value.(poly.converted)...)
# In the worst case, we return to drawing the polygon as a mesh + lines.
else
draw_poly_as_mesh(scene, screen, poly)
end
end

# Override `is_cairomakie_atomic_plot` to allow `poly` to remain a unit,
# instead of auto-decomposing in lines and mesh.
is_cairomakie_atomic_plot(plot::Poly) = true

"""
Fallback method for args without special treatment.
"""
function draw_poly(scene::Scene, screen::Screen, poly, args...)
draw_poly_as_mesh(scene, screen, poly)
end

function draw_poly_as_mesh(scene, screen, poly)
draw_plot(scene, screen, poly.plots[1])
draw_plot(scene, screen, poly.plots[2])
end


# in the rare case of per-vertex colors redirect to mesh drawing
function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2}, color::AbstractArray, model, strokecolor, strokewidth)
# As a general fallback, draw all polys as meshes.
# This also applies for e.g. per-vertex color.
function draw_poly(scene::Scene, screen::Screen, poly, points, color, model, strokecolor, strokestyle, strokewidth)
draw_poly_as_mesh(scene, screen, poly)
end

Expand Down Expand Up @@ -150,6 +157,7 @@ function polypath(ctx, polygon)
end

draw_poly(scene::Scene, screen::Screen, poly, polygon::Polygon) = draw_poly(scene, screen, poly, [polygon])
draw_poly(scene::Scene, screen::Screen, poly, multipolygon::MultiPolygon) = draw_poly(scene, screen, poly, multipolygon.polygons)
draw_poly(scene::Scene, screen::Screen, poly, circle::Circle) = draw_poly(scene, screen, poly, decompose(Point2f, circle))

function draw_poly(scene::Scene, screen::Screen, poly, polygons::AbstractArray{<:Polygon})
Expand Down
2 changes: 2 additions & 0 deletions CairoMakie/test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[deps]
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeoInterfaceMakie = "0edc0954-3250-4c18-859d-ec71c1660c08"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
ReferenceTests = "d37af2e0-5618-4e00-9939-d430db56ee94"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11 changes: 6 additions & 5 deletions CairoMakie/test/rasterization_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function svg_has_image(x)
save(path, x)
# this is rough but an easy way to catch rasterization,
# if an image element is present in the svg
return !occursin("<image id=", read(path, String))
return occursin("<image id=", read(path, String))
end
end

Expand All @@ -18,13 +18,14 @@ end
pl = poly!(ax, Makie.GeometryBasics.Polygon(pts))

@testset "Unrasterized SVG" begin
@test svg_has_image(fig)
@test !svg_has_image(fig)
end

@testset "Rasterized SVG" begin
lp.rasterize = true
@test !svg_has_image(fig)
@test svg_has_image(fig)
lp.rasterize = 10
@test !svg_has_image(fig)
@test svg_has_image(fig)
end
end

end
15 changes: 15 additions & 0 deletions CairoMakie/test/svg_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ end
@test svg_isnt_rasterized(poly(BezierPath([
MoveTo(0.0, 0.0), LineTo(1.0, 0.0), LineTo(1.0, 1.0), CurveTo(1.0, 1.0, 0.5, 1.0, 0.5, 0.5), ClosePath()
])))
@test !svg_isnt_rasterized(poly(rand(Point2f, 10); color = rand(RGBAf, 10)))

poly1 = Makie.GeometryBasics.Polygon(rand(Point2f, 10))
@test svg_isnt_rasterized(poly(Makie.GeometryBasics.MultiPolygon([poly1, poly1])))
@test svg_isnt_rasterized(poly(Makie.GeometryBasics.MultiPolygon([poly1, poly1]), color = :red))
@test svg_isnt_rasterized(poly(Makie.GeometryBasics.MultiPolygon([poly1, poly1]), color = [:red, :blue]))

@testset "GeoInterface polygons" begin
using GeoInterface, GeoInterfaceMakie
poly2 = GeoInterface.convert(GeoInterface.Wrappers, poly1)
@test svg_isnt_rasterized(poly(poly2))
@test svg_isnt_rasterized(poly(poly2, color = :red))
@test svg_isnt_rasterized(poly(GeoInterface.Wrappers.MultiPolygon([poly2, poly2]), color = [:red, :blue]))
end

end

@testset "reproducable svg ids" begin
Expand Down
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
GridLayoutBase = "3955a311-db13-416c-9275-1d80ed98e5e9"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Isoband = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
Expand Down Expand Up @@ -83,7 +82,6 @@ GeometryBasics = "0.4.2"
GridLayoutBase = "0.10"
ImageIO = "0.2, 0.3, 0.4, 0.5, 0.6"
InteractiveUtils = "1.0, 1.6"
IntervalArithmetic = "<0.22.6"
IntervalSets = "0.3, 0.4, 0.5, 0.6, 0.7"
Isoband = "0.1"
KernelDensity = "0.5, 0.6"
Expand Down
4 changes: 2 additions & 2 deletions docs/makedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pagefind = let
end
success(`$pagefind`)

# copy NEWS file over to documentation
# copy CHANGELOG file over to documentation
cp(
joinpath(@__DIR__, "..", "NEWS.md"),
joinpath(@__DIR__, "..", "CHANGELOG.md"),
joinpath(@__DIR__, "news.md"),
force = true)

Expand Down
2 changes: 2 additions & 0 deletions src/basic_recipes/scatterlines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ $(ATTRIBUTES)
)
end

conversion_trait(::Type{<: ScatterLines}) = PointBased()


function plot!(p::Plot{scatterlines, <:NTuple{N, Any}}) where N

Expand Down

0 comments on commit 7f33ba3

Please sign in to comment.