Skip to content

Commit

Permalink
allow multi stroke for poly, fix #1514
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Dec 15, 2021
1 parent 83a90ef commit ac0483a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ReferenceTests/src/tests/short_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,9 @@ end

s
end

@cell "multipoly with multi strokes" begin
P = Polygon.([Point2f[[0.45, 0.05], [0.64, 0.15], [0.37, 0.62]],
Point2f[[0.32, 0.66], [0.46, 0.59], [0.09, 0.08]]])
poly(P, color = [:red, :green], strokecolor = :blue, strokewidth = 2)
end
14 changes: 14 additions & 0 deletions src/basic_recipes/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ function plot!(plot::Poly{<: Tuple{<: Union{Polygon, AbstractVector{<: PolyEleme
inspectable = plot.inspectable
)
outline = lift(to_line_segments, geometries)
stroke = lift(outline, plot.strokecolor) do outline, sc
if !(meshes[] isa Mesh) && meshes[] isa AbstractVector && sc isa AbstractVector && length(sc) == length(meshes[])
idx = 1
return map(outline) do point
if isnan(point)
idx += 1
end
return sc[idx]
end
else
return sc
end
end

lines!(
plot, outline, visible = plot.visible,
color = plot.strokecolor, linestyle = plot.linestyle,
Expand Down

0 comments on commit ac0483a

Please sign in to comment.