-
-
Notifications
You must be signed in to change notification settings - Fork 295
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 Makie.AbstractPattern
as color in CairoMakie
for non-mesh plots
#2106
Conversation
Makie.AbstractPattern
Makie.AbstractPattern
as color in CairoMakie
for non-mesh plots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try this out soon but it looks good so far! Thanks for the PR :)
Cairo.set_source_rgba(screen.context, rgbatuple(to_color(color))...) | ||
if color isa Makie.AbstractPattern | ||
cairopattern = Cairo.CairoPattern(color) | ||
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also set the filter so that Cairo doesn't interpolate...
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT); | |
Cairo.pattern_set_extend(cairopattern, Cairo.EXTEND_REPEAT); | |
Cairo.pattern_set_filter(cairopattern, Cairo.FILTER_NEAREST); # or something like this anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, why no interpolation? should make diagonal line patterns look better no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - was looking at it from the perspective of ImagePattern, where you may not want the pattern to be interpolated. Maybe we could make this user-configurable somehow, perhaps by checking the interpolate
keyword...
Co-authored-by: Anshul Singhvi <anshulsinghvi@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, and looks good so far!
This looks mergeable to me.
At a later point I would like to have a vectorized version of LinePattern in CairoMakie, but that sounds like something for a different PR!
As for the Cairo recording surface: basically, one can draw on it using cairo_move_to
or cairo_line_to
, and then "replay" it onto a surface. It would be something like drawing lines across the surface in a pattern and the rest of the code would likely remain the same.
Demo
Description
fix #1385
Type of change
Delete options that do not apply:
Checklist