Repository navigation
fix: with_pattern() handles a plain list of patterns as fill - #144
Merged
Merged
Conversation
* A list of grid patterns assigned directly to `grob$gp$fill` (i.e. without the "GridPatternList" class that `gpar()` adds) is now treated the same as one set via `gpar()`, matching how grid itself draws it. In particular a plain list of grouped gradients is now seen as relative to all the shapes (so they are no longer filled separately, each gradient relative to its own shape) and a one-element plain list gives each shape the bare pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gpar(fill = list(<patterns>))gives the fill grid's (unexported)"GridPatternList"class, but code that setsgrob$gp$fill <- list(<patterns>)directly ends up with a plainlist. Grid draws both the same (it re-validates thegpat draw time), but{gridpattern}checked the class directly:has_grouped_pattern_fill()didn't see a plain list of grouped gradients as grouped, sowith_pattern()filled each shape separately (each gradient relative to its own shape).shape_gps()handled a plain list of two or more patterns correctly only by accident, and didn't unwrap a one-element plain list.This came up via
{ggpattern}'swith_pattern()tracing (trevorld/ggpattern#174), which restores list fills (gradients) directly intogrob$gp$fill.Changes
is_pattern_list(): a non-empty list whose elements are all<GridPattern>objects (classed or plain). A bareis.list()would be too broad becausegpar()also keeps listcol/ltyvalues.has_grouped_pattern_fill()andshape_gps()use it. The two branches ofshape_gps()merge into one, sincerep_len()already drops the"GridPatternList"class.group = FALSE, including a one-element list) and for one-element listcol/ltybeing left as they are.with_pattern()is unreleased.Repro
🤖 Generated with Claude Code