Skip to content

Commit

Permalink
introduce stroke_depth_shift + forward normal depth_shift for Poly (#…
Browse files Browse the repository at this point in the history
…4058)

* introduce stroke_depth_shift + forward normal depth_shift

* remove ,

* correct spelling mistake

* add changelog
  • Loading branch information
SimonDanisch authored Jul 26, 2024
1 parent 4940530 commit 4c4eaa1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Introduce stroke_depth_shift + forward normal depth_shift for Poly [#4058](https://github.com/MakieOrg/Makie.jl/pull/4058).
- Use linestyle for Poly and Density legend elements [#4000](https://github.com/MakieOrg/Makie.jl/pull/4000).
- Bring back interpolation attribute for surface [#4056](https://github.com/MakieOrg/Makie.jl/pull/4056).
- Improved accuracy of framerate settings in GLMakie [#3954](https://github.com/MakieOrg/Makie.jl/pull/3954)
Expand Down
5 changes: 4 additions & 1 deletion MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,10 @@ Plots polygons, which are defined by
shading = NoShading

cycle = [:color => :patchcolor]

"""
Depth shift of stroke plot. This is useful to avoid z-fighting between the stroke and the fill.
"""
stroke_depth_shift = -1.0f-5
mixin_generic_plot_attributes()...
mixin_colormap_attributes()...
end
Expand Down
21 changes: 12 additions & 9 deletions src/basic_recipes/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ function plot!(plot::Poly{<: Tuple{Union{GeometryBasics.Mesh, GeometryPrimitive}
overdraw = plot.overdraw,
inspectable = plot.inspectable,
transparency = plot.transparency,
space = plot.space
space = plot.space,
depth_shift = plot.depth_shift
)
wireframe!(
plot, plot[1],
color = plot[:strokecolor], linestyle = plot[:linestyle], space = plot[:space],
linewidth = plot[:strokewidth], linecap = plot[:linecap],
visible = plot[:visible], overdraw = plot[:overdraw],
inspectable = plot[:inspectable], transparency = plot[:transparency],
colormap = plot[:strokecolormap]
color = plot.strokecolor, linestyle = plot.linestyle, space = plot.space,
linewidth = plot.strokewidth, linecap = plot.linecap,
visible = plot.visible, overdraw = plot.overdraw,
inspectable = plot.inspectable, transparency = plot.transparency,
colormap = plot.strokecolormap, depth_shift=plot.stroke_depth_shift
)
end

Expand Down Expand Up @@ -161,6 +162,7 @@ function plot!(plot::Poly{<: Tuple{<: Union{Polygon, AbstractVector{<: PolyEleme
transparency = plot.transparency,
inspectable = plot.inspectable,
space = plot.space,
depth_shift = plot.depth_shift
)

outline = lift(to_lines, plot, geometries)
Expand All @@ -185,7 +187,7 @@ function plot!(plot::Poly{<: Tuple{<: Union{Polygon, AbstractVector{<: PolyEleme
joinstyle = plot.joinstyle, miter_limit = plot.miter_limit,
space = plot.space,
overdraw = plot.overdraw, transparency = plot.transparency,
inspectable = plot.inspectable, depth_shift = -1f-5
inspectable = plot.inspectable, depth_shift = plot.stroke_depth_shift
)
end

Expand All @@ -195,13 +197,14 @@ function plot!(plot::Mesh{<: Tuple{<: AbstractVector{P}}}) where P <: Union{Abst
visible = plot.visible, shading = plot.shading, fxaa = plot.fxaa,
inspectable = plot.inspectable, transparency = plot.transparency,
space = plot.space, ssao = plot.ssao,
alpha=plot.alpha,
alpha = plot.alpha,
lowclip = get(plot, :lowclip, automatic),
highclip = get(plot, :highclip, automatic),
nan_color = get(plot, :nan_color, :transparent),
colormap = get(plot, :colormap, nothing),
colorscale = get(plot, :colorscale, identity),
colorrange = get(plot, :colorrange, automatic)
colorrange = get(plot, :colorrange, automatic),
depth_shift = plot.depth_shift
)

num_meshes = lift(plot, meshes; ignore_equal_values=true) do meshes
Expand Down

0 comments on commit 4c4eaa1

Please sign in to comment.