From f89efc383fb9d2e11210785718075c94ef7c9055 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 14 May 2024 23:03:33 +0200 Subject: [PATCH] Support glow for text (fixes for #3858) (#3866) * Support glow for text * Add reference test * Update examples3d.jl * forward glowwidth + glowcolor in Text for WGLMakie --------- Co-authored-by: Kipton Barros --- MakieCore/src/basic_plots.jl | 4 ++++ ReferenceTests/src/tests/examples3d.jl | 9 +++++++++ WGLMakie/src/particles.jl | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/MakieCore/src/basic_plots.jl b/MakieCore/src/basic_plots.jl index 1ca37e525ef..a28b9234178 100644 --- a/MakieCore/src/basic_plots.jl +++ b/MakieCore/src/basic_plots.jl @@ -499,6 +499,10 @@ Plots one or multiple texts passed via the `text` keyword. markerspace = :pixel "Controls whether the model matrix (without translation) applies to the glyph itself, rather than just the positions. (If this is true, `scale!` and `rotate!` will affect the text glyphs.)" transform_marker = false + "Sets the color of the glow effect around the text." + glowcolor = (:black, 0.0) + "Sets the size of a glow effect around the text." + glowwidth = 0.0 "The offset of the text from the given position in `markerspace` units." offset = (0.0, 0.0) "Specifies a linewidth limit for text. If a word overflows this limit, a newline is inserted before it. Negative numbers disable word wrapping." diff --git a/ReferenceTests/src/tests/examples3d.jl b/ReferenceTests/src/tests/examples3d.jl index 890ddde407d..5d7a08a5e90 100644 --- a/ReferenceTests/src/tests/examples3d.jl +++ b/ReferenceTests/src/tests/examples3d.jl @@ -394,6 +394,15 @@ end meshscatter(positions, color=RGBAf(0.9, 0.2, 0.4, 1), markersize=0.05) end +@reference_test "Text glow and overdraw" begin + p1 = Point3f(0,0,0) + p2 = Point3f(1,0,0) + f, ax, pl = meshscatter([p1, p2]; markersize=0.3, color=[:purple, :yellow]) + text!(ax, p1; text="A", align=(:center, :center), glowwidth=10.0, glowcolor=:white, color=:black, fontsize=40, overdraw=true) + text!(ax, p2; text="B", align=(:center, :center), glowwidth=20.0, glowcolor=(:black, 0.6), color=:white, fontsize=40, overdraw=true) + f +end + @reference_test "Animated surface and wireframe" begin function xy_data(x, y) r = sqrt(x^2 + y^2) diff --git a/WGLMakie/src/particles.jl b/WGLMakie/src/particles.jl index 8c4e1d93323..535105ee82d 100644 --- a/WGLMakie/src/particles.jl +++ b/WGLMakie/src/particles.jl @@ -289,7 +289,9 @@ function create_shader(scene::Scene, plot::Makie.Text{<:Tuple{<:Union{<:Makie.Gl :uv_offset_width => uv_offset_width, :transform_marker => get(plot.attributes, :transform_marker, Observable(true)), :billboard => Observable(false), - :depth_shift => get(plot, :depth_shift, Observable(0f0)) + :depth_shift => get(plot, :depth_shift, Observable(0f0)), + :glowwidth => plot.glowwidth, + :glowcolor => plot.glowcolor, ) return scatter_shader(scene, uniforms, plot_attributes)