Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support glow for text (fixes for #3858) #3866

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
9 changes: 9 additions & 0 deletions ReferenceTests/src/tests/examples3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion WGLMakie/src/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading