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

Split marker_offset from quad_offset #4594

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Split marker_offset from quad_offset #4594

wants to merge 17 commits into from

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Nov 16, 2024

Description

For text we have:

  • a position that acts as an anchor for the displayed string
  • a char_offset which gives the position of each character relative to the string anchor point
  • a quad_offset which gives places the rectangle containing the char relative to the character position

The user offset is included in char_offset. Both act in markerspace, though quad_offset also includes billboarding.

This pr effective translates this behavior to scatter. It now always centers, i.e. does the equivalent to character layouting under the hood, and considers marker_offset a pure user attribute. This removes the need for

replace_automatic!(plot, :marker_offset) do
# default to middle
return lift(plot, plot[:markersize]) do msize
return to_2d_scale(map(x -> x .* -0.5f0, msize))
end
end

in calculated_attributes, and it also fixes some niche errors:

  • Bezierpath markers ignoring marker_offset (GLMakie, WGLMakie, CairoMakie)
  • Char markers being complicated to center (GLMakie, WGLMakie) (using 0.5markersize doesn't quite work here)
  • FastPixel ignoring marker_offset (GLMakie)
  • marker_offset not working without billboarding in 3D (GLMakie, WGLMakie)
  • Image markers translating in the wrong direction (CairoMakie)
  • rotation acting on the position rather than marker for Rect (and FastPixel) markers (CairoMakie)

Changes:

  • marker_offset is now independent of rotation. (So rotation = pi/2 doesn't turn (x, 0) into a translation in y direction) (GLMakie, WGLMakie)

Fixes #4383

Refimg before & after

2D no rotation

FastPixel is expected to be square in GLMakie, falls back onto Rect for other backends

GLMakie WGLMakie CairoMakie
before Screenshot 2024-11-17 173436 Screenshot 2024-11-17 173837 Screenshot 2024-11-17 174035
after GLMakie_scatter marker_offset 2D WGLMakie_scatter marker_offset 2D CairoMakie_scatter marker_offset 2D

2D with billboarded rotation

Skipped FastPixel as it doesn't support rotation

GLMakie WGLMakie CairoMakie
before Screenshot 2024-11-17 173516 Screenshot 2024-11-17 173900 Screenshot 2024-11-17 174047
after GLMakie_scatter marker_offset 2D with billboarded rotation WGLMakie_scatter marker_offset 2D with billboarded rotation CairoMakie_scatter marker_offset 2D with billboarded rotation

3D with Quaternion rotation

Everything is wrong in CairoMakie here, especially with space = :data. I assume fixing this requires reworking the scatter code at a larger scale, so I didn't bother with it here. Some placements improved regardless though.

GLMakie WGLMakie CairoMakie
before Screenshot 2024-11-17 173609 Screenshot 2024-11-17 173916 image
after GLMakie_scatter marker_offset 3D with rotation WGLMakie_scatter marker_offset 3D with rotation Screenshot 2024-11-17 153837

Attribute Example

image

Type of change

Could be considered breaking as marker_offset = Vec2f(0, 0) is now a centered marker instead of a bottom-left aligned marker. But with BezierPath, i.e. default markers not working with marker_offset we could also consider marker_offset to not really be supported right now.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Updated docstring
  • Added or changed relevant sections in the documentation
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@MakieBot
Copy link
Collaborator

MakieBot commented Nov 16, 2024

Benchmark Results

SHA: 272a41db69c1d331cb0f8a7982e5842310a0b700

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@jkrumbiegel
Copy link
Member

I'd consider this a bug fix

@ffreyer
Copy link
Collaborator Author

ffreyer commented Nov 17, 2024

This is ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready to review
Development

Successfully merging this pull request may close these issues.

Scatter marker_offset is broken
3 participants