gridpattern v1.6.0 (development)
Breaking Changes
-
A length-one
NaNvalue of any pattern parameter is now treated as unset so pattern-specific (or else generic) defaults apply (a parameter without any default is thenNULLi.e. the same as if it wasn’t supplied so new ggpattern aesthetics and new defaults don’t change what aNaNmeans). This is the new ggpattern default for its aesthetics that should fall back to the pattern’s defaults (e.g. the “wave” frequency of1 / spacing, the “regular_polygon” scale0.5, the “text” shape"X", and the “crosshatch” / “weave”pattern_fill2ofpattern_fill). AnNAvalue keeps its meaning (e.g. a transparent colour or a “pch” shape that draws nothing) except forpattern_type,pattern_subtype,pattern_gravity, andpattern_resfor which a length-oneNAis still also treated as unset. A few pattern defaults were updated to match the previous {ggpattern} defaults (that are now unset) to minimize visual changes downstream:- The default
shapeofgrid.pattern_regular_polygon()(and the registered defaultpattern_shapeof the “regular_polygon” pattern) is now"convex6"(hexagons) instead of"convex4". Useshape = "convex4"to restore the previous appearance. - The default
fillofgrid.pattern_magick()is nowgp$fill %||% "grey80"(previously"grey20"ignoringgp$fill) matching the generic defaultpattern_fillthatpatternGrob()already used for the “magick” pattern. Usefill = "grey20"to restore the previous appearance. - The default linewidth (when none of
linewidth,size, norgp$lwdis given) is now0.5instead of1for bothpatternGrob()and thegrid.pattern_<name>()functions so default lines are now half as thick. The generic default ofpattern_sizeis likewise nowgp$lwd %||% 0.5. - The spare ggpattern aesthetics
pattern_phaseandpattern_option_1-pattern_option_5(which no builtin pattern uses) now have a generic default of0A custom pattern drawn bypatternGrob()that usedparams$pattern_option_1 %||% my_default(or checkedis.null(params$pattern_phase)) to pick its own default when unset now always gets0and should instead register its defaults withregister_pattern(defaults = ).
- The default
The default resolution
pattern_res(resargument) of array patterns, the “gradient” pattern, and the raster fallbacks ofalphaMaskGrob()andclippingPathGrob()(if the package optionggpattern_resis unset) is now computed when drawn from the resolution of the graphics device instead of being72pixels per inch:1.14times the device resolution (e.g. about82onpdf()/svg()devices and342on a300ppipng()). This is sharper on high resolution devices but uses more memory and time. A numericlegendkey’s default resolution is1.3 * legend * pattern_key_scale_factortimes the device resolution so array patterns in legend keys resemble those in the (larger) plot panels. These match the resolutions ggpattern (<= 1.3.1) computed itself. Theresargument of thegrid.pattern_<name>()functions,alphaMaskGrob(), andclippingPathGrob()now defaults toNULL(unset).pattern_units(unitsargument) may no longer be “npc”, “native”, nor “null” (now an error, #115). Pattern lengths (e.g.pattern_spacing,pattern_xoffset, andpattern_yoffset) were always converted along the viewport’s width so “npc” and “native” ignored the viewport’s height (even for vertical offsets) and “null” lengths are zero (which threw an obscure error). Use “snpc” (the default) for lengths relative to the viewport or an absolute unit such as “cm” or “in”.
New features
The
legendargument ofpatternGrob()/grid.pattern()may now be a non-negative numbersto draw a legend key showing (the centre of) the pattern as it would be drawn in an areastimes the width and height of the key (TRUEis equivalent to1andFALSEto0). The pattern is drawn in a centred viewportstimes larger than the key so all relative lengths (e.g. “snpc” spacings, offsets, and wave amplitudes, including those of custom patterns) scale together while absolute lengths (e.g. line widths, font sizes, “cm” units, and array pixels) don’t. The pattern functions themselves are still passed a logicallegendvalue. ggpattern now uses this to scale its legend keys instead of rescalingpattern_spacing,pattern_xoffset, andpattern_yoffsetitself.A numeric
legendkey is now zoomed by thepattern_key_scale_factorparameter (key_scale_factorargument): the legend viewport islegend * pattern_key_scale_factortimes larger than the key and ifpattern_unitsisn’t “snpc” then the pattern’skey_scalingparameters are multiplied by (a power of)pattern_key_scale_factorso legend keys of patterns with absolute units (e.g. “cm”) can be zoomed too.register_pattern()’s newkey_scalingargument (a named vector of powers) sets these parameters: by defaultc(pattern_spacing = 1, pattern_xoffset = 1, pattern_yoffset = 1)while the “wave” pattern also zoomspattern_amplitude(1) andpattern_frequency(-1). This zoom is applied after all the defaults are filled in so (function) defaults always see the parameters as drawn in the plot e.g. a registered default forpattern_key_scale_factormay zoom out a legend key more for larger spacingslist(pattern_spacing = 0.025, pattern_key_scale_factor = function(params, gp) min(1, 0.025 / params$pattern_spacing)). A logicallegend(as passed by ggpattern 1.3.1 and earlier, which zoom their keys themselves) is not zoomed bypattern_key_scale_factor. Previously only the “magick” pattern usedpattern_key_scale_factor(which it still does for any legend key).prefer_pattern()’s newmust_existargument controls what happens if a preferred pattern isn’t (yet) registered:NA(the default) warns,TRUEerrors, andFALSEneither warns nor loads the pattern’s package (useful in an.Rprofile). It likewise controls what happens if the user has more than one pattern with that name (via the legacyggpattern_geometry_funcs/ggpattern_array_funcsoptions). Previously preferring a pattern that wasn’t registered was always an error.local_prefer_pattern()sets pattern preferences until the current function (or test) exits and then restores any previous preferences (#113).local_pattern()’s newpreferargument also prefers the registered pattern until the current function (or test) exits ifTRUE.has_registered_pattern()returns whether a pattern name is taken (even if it doesn’t resolve e.g. because of a conflict) i.e. whether registering a pattern with that name would clobber or conflict with a pre-existing pattern.as.patternGrob()creates a pattern grob whose boundary is (the area filled by) an existing grid grob (#131).with_pattern()fills each area of an object with a pattern (#131). It has methods for grid grobs, gLists, (plain) lists, andNULL(returned as it is).area_boundaries()splits a grid grob into one boundary grob per such area.-
Several conditions now have classes so they can be caught or muffled:
-
"gridpattern_ambiguous_pattern"(fieldpattern): the error for a pattern name that can’t be resolved because it is registered by more than one owner. -
gridpattern_area_mismatch:with_pattern()’s error when a pattern parameter (orpool) has the wrong number of values per area (fieldsarg,n_expected(the expected number of values),n_given, andunit("area","grob", or"pool")). -
"gridpattern_no_method"(fieldx_class, the first class of the object):with_pattern()’s error for an object (or list element) without awith_pattern()method. -
"gridpattern_pattern_conflict"(fieldpattern): the messagesregister_pattern()gives when a newly registered pattern conflicts with (or is masked by) another pattern. -
"gridpattern_pool_mismatch":with_pattern()’s error when apoolhas areas of more than one grob. -
"gridpattern_unknown_pattern"(fieldpattern, the name that couldn’t be resolved): the error for an unknown pattern name (or a preferred"owner::name"pattern that isn’t registered).
-
Bug fixes and minor improvements
Resolving pattern names (e.g. by
patternGrob()) andregistered_patterns()/conflicting_patterns()are faster when many patterns are registered (e.g. both are about 20 times faster with 1000 registered patterns).registered_patterns()andconflicting_patterns()no longer load the package of a preferred pattern (previously the first call omitted that package’s patterns and listed no pattern with that name as active).A qualified pattern name
"pkg::name"no longer resolves to a stale registration left behind by a{pkg}that was unloaded and can no longer be loaded (e.g. because it was removed) sohas_pattern()now returnsFALSEandprefer_pattern(must_exist = TRUE)now errors for it.The raster fallbacks of
alphaMaskGrob()andclippingPathGrob()(used by the “hatch”, “line”, “rose”, and “text” patterns when masks / clipping paths aren’t supported by the graphics device) now only rasterise the (pixel-snapped) bounding box of the masker / clipper within the viewport instead of the whole viewport (if it can be computed withgrobCoords()in R 4.2+). This is much faster and uses much less memory for small boundaries in large viewports, in particular for a numericlegend(e.g. ggpattern legend keys).When the
png_devicedoesn’t support clipping paths the raster fallback ofclippingPathGrob()now ignores the graphical parameters of the clipper (and its children) like native clipping paths (previously e.g. a clipper withfill = NAclipped to the outline drawn by its stroke) and its clip edge is now anti-aliased (if thepng_deviceanti-aliases) instead of keeping or dropping whole pixels (#117).The (forced) child of
alphaMaskGrob()is now always named"alpha_mask"and the (forced) child ofclippingPathGrob()is now always named"clip"(previously the raster fallbacks drawn with native masks / clipping paths on a ragg orpng_devicedevice used an automaticgridname).If ragg (>= 1.2.0) isn’t installed the default
png_deviceof the raster fallbacks ofalphaMaskGrob()andclippingPathGrob()(and the patterns that use them) is nowgrDevices::png(type = "cairo")if R has Cairo (#128). Previously it wasragg::agg_png()(if an older ragg was installed, which lacks clipping paths and masks) or elsegrDevices::png()which on Windows always uses GDI, on macOS uses Quartz (which only supports clipping paths in R >= 4.3.0 and alpha masks in R >= 4.5.0), and elsewhere doesn’t use Cairo if R lacks Pango (getOption("bitmapType")is then"Xlib").grid::grobCoords()of apatternGrob()is now the coordinates of its boundary (without building the pattern).The “hatch” pattern types drawn by other patterns (e.g. “or” circles, “olive”, “proper” waves, Goodman “steel” and “copper”, and Unicode “cendree” checkers) now pass on
pattern_units,pattern_xoffset, andpattern_yoffset. Previously their spacing was always interpreted as “snpc” units (while their density was computed from the spacing inpattern_unitsunits) and their offsets were ignored.-
The builtin patterns’ registered defaults now agree with the defaults of their
grid.pattern_<name>()functions (sopatternGrob()/ ggpattern andgrid.pattern_<name>()render the same when a parameter is unset):- “hatch” registers
pattern_subtype = "combinatorial"(previously an unset subtype was already treated as"combinatorial"). - “text” registers
pattern_shape = "X"(previously the generic1). - The
aspect_ratioargument ofgrid.pattern_gradient(),grid.pattern_image(),grid.pattern_magick(),grid.pattern_placeholder(), andgrid.pattern_plasma()now defaults toNA(use the aspect ratio of the current viewport, aspatternGrob()does) instead of1so their raster approximations are no longer distorted in non-square viewports.
- “hatch” registers
The “circle”, “regular_polygon”, “rose”, “text”, and “weave” patterns (and the patterns drawn with them e.g. “pch”, “polygon_tiling”, and the “cendree” hatch) are much faster when the pattern grid is dense (many points per viewport) (#119).
Patterns now draw nothing (a
grid::nullGrob()) instead of throwing an error (or building a huge pattern grid) in a viewport whose width or height is smaller than a device pixel (including zero or negative) e.g. a ggpattern panel squeezed to nothing (or beyond) by a wide legend in a small plot pane (#119). Previously the geometry patterns threwinvalid '(to - from)/by'orwrong sign in 'by' argument(their default “snpc” spacing was zero or negative) and the “plasma” pattern threwthe dims contain negative values.The patterns with a two-dimensional grid (“circle”, “regular_polygon”, “rose”, “text”, “weave”, and the hatch types they draw e.g. “cendree”) now draw nothing (a
grid::nullGrob()) instead of possibly exhausting memory when their grid would have more than ten million points (#119).The geometry patterns drawn with sf (e.g. “circle”, “crosshatch”, “regular_polygon”, “stripe”, “wave”, and “weave”) now fill every lobe of a self-intersecting boundary (e.g. a “bow tie” polygon). Previously only one lobe was filled (the zero-width buffer that cleaned up the boundary kept only one). The boundary is now first made valid with
sf::st_make_valid()(which needs GEOS 3.8 (2019) or newer, otherwise the previous behaviour is kept).The “seagal” and “seagalbw” placeholder types work again (their URLs used a nonexistent
www.subdomain ofstevensegallery.lucidinternets.com, #118).Placeholder types that return greyscale images (e.g. “murray”, “murraybw”, “picsumbw”, and “seagalbw”) no longer throw an error (their single channel images weren’t promoted to RGBA arrays).
An unknown placeholder
typenow actually falls back to the “bear” placeholder (as its warning claims) instead of a “dummy” placeholder image. A placeholdertypethat isn’t length one now also falls back to “bear” (the defaulttype) instead of “kitten”.The “stripe”, “crosshatch”, and “weave” patterns now cycle multiple
fill(andfill2),colour,linewidth,linetype, and (except for “weave”)densityvalues by stripe like the “wave” and “regular_polygon” patterns do: the stripes of each set of values are clipped to the boundary separately (so these patterns’ grobs are nowgTrees with a polygon grob child per set of values). Previously multiplefill,colour,linewidth, andlinetypevalues were recycled over the pieces of the stripes clipped to the boundary (in the order of thesf::st_intersection()output) so when the boundary was several polygons a stripe could change colour from polygon to polygon and multipledensityvalues were an error (“weave” still needs a singledensitybut now says so clearly). The stripes are counted from the stripe through the centre of the viewport so for a single polygon they may now start with a different colour than before.The “wave” pattern now cycles multiple
densityvalues by row like its other parameters (previously an error since thedensityof each row was recycled but never used). Its grob is now named “wave” (previously it was misnamed “regular_polygon”).A
patternofNAdraws nothing inpatternGrob()/grid.pattern()(like"none") instead of being an error when the grob is drawn.
gridpattern v1.5.1
CRAN release: 2026-10-28
Breaking Changes
- Custom patterns are no longer given generic default values for the
pattern_amplitudeparameter nor for the ambient noise parameters (pattern_fractal,pattern_octaves, etc.). These are now pattern-specific defaults of the builtin “wave” and “ambient” patterns. A custom pattern that reads them should now set its own defaults withregister_pattern()’sdefaultsargument. The generic defaults forpattern_frequencyandpattern_gravityare now the constants0.1and"center"(matching ggpattern) instead of1 / pattern_spacingand a function ofpattern_type; the “wave”, “ambient”, and “image” patterns override them.pattern_subtypenow has a generic default ofNA(matching ggpattern) and likepattern_typeandpattern_gravityanNAvalue is treated as unset so pattern-specific defaults apply. AnNApattern_resis also treated as unset (previously an obscure error).
New Features
-
register_pattern()is now the recommended way for packages to register patterns (in their.onLoad()function, ideally wrapped inrlang::on_package_load()) instead of setting theggpattern_geometry_funcs/ggpattern_array_funcsglobal options which may clobber other registrations (#108).- Patterns are owned by either the package that registered them or the user.
-
register_pattern()’sdefaultsargument sets pattern-specific default parameter values (constants or functions of the other parameters, named e.g.pattern_spacingorfill; unprefixed names are an error unless declared in theunprefixedargument). The builtin patterns now use this to register their pattern-specific defaults. -
patternGrob()caches the pattern resolved when the grob is created so redraws (e.g. resizing an interactive device) still work if the pattern is later unregistered or masked. - Package patterns (including builtins) may be referred to by their qualified name e.g.
"gridpattern::stripe"or"pkg::name".
unregister_pattern()can be used to unregister a pattern.prefer_pattern("owner::name")sets preferences andunprefer_pattern(name)removes them (both are vectorized and return the previous preferences so they can be restored). Bare pattern names resolve to the pattern preferred byprefer_pattern()(if any) and otherwise to the pattern of the only owner (the user, gridpattern, or a package) with that name. If more than one owner has a pattern with that name there is a conflict and an error asks for either a qualified name or aprefer_pattern()preference (similar to the conflicted package).conflicting_patterns()lists patterns whose bare names are shared by more than one patternhas_pattern()returns whether a pattern name resolves to a pattern.local_pattern()registers a pattern until the current function (or test) exits and then restores any previous registration (useful in tests and examples).
Bug fixes and minor improvements
- Fixes a bug where the “hatch” pattern failed when
pattern_subtypewasNA(the ggpattern default) instead ofNULL(#106). - Patterns set via the global options may now share a name with a builtin pattern (resolved with
prefer_pattern()) instead of always throwing an error. - Name clashes between patterns now only throw an error when the conflicted pattern name is used rather than for every pattern.
gridpattern v1.4.2
CRAN release: 2026-06-23
Breaking Changes
- The
"indented"(formerly"triangle") wave type now uses a wider stroke in order to better match the apparent stroke widths of the new wave types. Users who relied on the previous visual appearance should reducedensityto compensate.
New Features
New “hatch” pattern with corresponding
grid.pattern_hatch()andnames_hatch()(#97).New “line” pattern with corresponding
grid.pattern_line(). Unlike the “stripe” pattern which fills bands with solid colour, “line” draws stroked lines using the device’s native line rendering, enabling all of R’s built-inlinetypevalues (including"dotdash","twodash", and custom line types specified as hex strings per?par).The preexisting “wave” pattern gains ten new
typevalues, areverseparameter, astaggerparameter, andnames_wave(#100, #101).New
mix_col()that mixes colors via Munsell color space usingaqp::mixMunsell(). Requires the suggested package aqp.
Bug fixes and minor improvements
Fixes a bug where geometry-based patterns (e.g. “stripe”, “crosshatch”, “wave”) could silently disappear in small viewports when
pattern_key_scale_factorwas a relatively large value (#95).-
The following “placeholder” pattern updates (#83):
-
The following placeholder pattern names are now serviced by placecats.com
- “kitten” and “kittenbw”
-
The following placeholder pattern names are now serviced by placehold.co
- “placeholder” and “placeholderbw”
The “placeholderbw” name now provides a pure black-and-white image (i.e. no grey).
-
Fixes a bug where the
"wavy"(aliases"sine","undy") and"indented"(alias"triangle") wave types had an effective wavelength of(n-1)/ntimes the requested wavelength, wherenis the number of wavelength-spaced grid positions spanning the viewport.
gridpattern v1.3.1
CRAN release: 2025-01-16
- New pattern “aRtsy” with corresponding
grid.pattern_aRtsy()with patterns powered by the aRtsy package (#87).
gridpattern v1.2.2
CRAN release: 2024-06-03
Bug fixes and minor improvements
grid.pattern_weave()adds the newunitsparameter that most other “geometry” pattern functions received in gridpattern v1.2.1.The “polygon_tiling” pattern should now respect the
unitsparameter if set to a value different from the “snpc” default (#82).For the “polygon_tiling” pattern
type = "18.18.3*"the size of the eighteen-sided polygons have been increased a teeny bit and this polygon tiling should look a bit cleaner.-
The following “placeholder” pattern updates (#83):
-
The following placeholder pattern names are now serviced by lucidinternets.com:
- “cage” and “cagebw”
- “murray” and “murraybw”
- “seagal” and “seagalbw”
-
The following placeholder pattern names have been removed since their associated web service no longer works:
- “lorempixel” and “lorempixelbw” (service unavailable since 2022)
- “placeimg” and “placeimgbw” (support officially ended July 2023)
The “dummybw” name now provides a pure black-and-white image (i.e. no grey).
Fixes a regression for the “placeholderbw” name where it redirected to the “seagal” name instead of “placeholder”.
-
gridpattern v1.2.1
CRAN release: 2024-05-01
Breaking Changes
- The default
typefor the “placeholder” pattern is now “bear” instead of “kitten”. Explicitly settype = "kitten"to continue to use the “kitten” placeholder but note that although the “kitten” placeholder website isn’t completely down it has been buggy recently (#73).
New Features
patternFill()wrapspatternGrob()to return agrid::pattern()fill object (#70).The “geometry” patterns (e.g. “circle”, “stripe”, etc.) now allow the
fillto be pattern fills (#67).The “geometry” patterns (e.g. “circle”, “stripe”, etc.) now allow the new
unitsparameter to set whichgrid::unit()to use for the thespacing,xoffset, andyoffsetparameters (and for the “wave” pattern also theamplitudeandfrequencyparameters) (#58). By default it will continue to be “snpc” units but can now be changed to “cm”, “in”, etc.-
update_alpha()updates fill colour and/or pattern transparency.- It is a fork of
ggplot2::fill_alpha()by @teunbrand. - It does not depend on ggplot2 or scales.
- It does not throw an error with a length one list of a vector of multiple colours.
- It is available as a “standalone” file. You may copy its source under the permissive MIT license into your own R package by either using
usethis::use_standalone("trevorld/gridpattern", "standalone-update_alpha.R")or simply copyingstandalone-update_alpha.Rinto your R directory and addinggrDevices,grid, andrlangto theImportsof yourDESCRIPTIONfile.
- It is a fork of
For completeness there is now a new “fill” pattern with corresponding
grid.pattern_fill()which draws a simple fill pattern.For completeness there is now a
grid.pattern_none()corresponding to the previously supported “none” pattern which draws nothing.
Bug fixes and minor improvements
- The
wavepattern no longer quietly and incorrectly ignores thefrequencyparameter. The effective wavelength of the wave pattern is now1 / frequencyinstead ofspacing. Howeverfrequencywill continue to default to1 / spacing. -
clippingPathGrob()can now more efficiently compute arasterGrob()approximation viaragg::agg_capture()and forpng_devicefunctions that support the clipping path feature such aspng(type = "cairo")(#74). -
alphaMaskGrob()can now more efficiently compute arasterGrob()approximation forpng_devicefunctions that support the alpha mask feature such aspng(type = "cairo")(#75). -
alphaMaskGrob()andclippingPathGrob()now switch back to the previously open graphics device if they open and close any new graphics devices.
gridpattern v1.1.0
CRAN release: 2023-10-03
New Features
-
reset_image_cache()resets the image cache used bygrid.pattern_image()andgrid.pattern_placeholder()to store images (#63).
Bug fixes and minor improvements
- The function
guess_has_R4.1_features()is now available as a “standalone” file. You may copy its source under the permissive MIT No Attribution (MIT-0) license into your own R package by either usingusethis::use_standalone("trevorld/gridpattern", "standalone-guess_has_R4.1_features.R")or simply copyingstandalone-guess_has_R4.1_features.Rinto yourRdirectory and addinggrDevicesandutilsto theImportsof yourDESCRIPTIONfile. - If vdiffr has been updated to at least v1.0.6 (released 2023-08-25) then
guess_has_R4.1_features()should now always correctly guess R4.1 feature support for thesvglite::svglite()andvdiffr:::svglite()graphics devices.
gridpattern v1.0.1
CRAN release: 2022-08-16
Bug fixes and minor improvements
-
guess_has_R4.1_features()can now also take advantage ifdev.capabilities()explicitly indicates that a feature is not supported in active graphics device. - To match aesthetic changes in ggplot2 one may now use the parameter
linewidthto set polygon/path line widths ingrid.pattern_circle(),grid.pattern_crosshatch(),grid.pattern_pch(),grid.pattern_polygon_tiling(),grid.pattern_regular_polygon(),grid.pattern_stripe(),grid.pattern_rose(),grid.pattern_wave(), andgrid.pattern_weave(). For backwards compatibility one may continue to usesizeas well. Continue to usesize(orgp) to set the fontsize ingrid.pattern_text(). Bothpattern_linewidthandpattern_sizewill be available for use in custom patterns (#57).
gridpattern v0.5.3
CRAN release: 2022-03-22
Bug fixes and minor improvements
Fixes bug with
grid.pattern_image()withtype = "tile"(#47). Additionallygrid.pattern_image()now supportsgravityargument whentype = "tile".-
If the active graphics device has also implemented the new R 4.2
dev.capabilities()support thenguess_has_R4.1_features()can now better guess R 4.1 graphic feature support when called within R 4.2.- In particular
guess_has_R4.1_features()can now better guess R 4.1 graphic feature support in the{grDevices}bitmap devices (i.e.bmp(),jpeg(),png(),tiff()) when called within R 4.2 on Windows. Previously it was not possible to easily distinguish on Windows if the device was called withtype = "windows"ortype = "cairo"and hence we had to conservatively guess no such support even iftype = "cairo"had been specified (and within R 4.1 we must still conservatively do so). - Also if in the future any graphic devices add R 4.1 graphic feature support as well as R 4.2
dev.capabilities()support then we should now be able to correctly guess such support within R 4.2 without needing to manually updateguess_has_R4.1_features().
- In particular
guess_has_R4.1_features()now supports an argumentfeatureswhich allows one to limit the guessing of R4.1 feature support to a subset ofc("clippingPaths", "gradients", "masks", "patterns"). Although all known graphic devices either implements all or none of these features this need not hold true in the future.
gridpattern v0.5.1
CRAN release: 2022-02-16
Breaking Changes
-
grid.pattern_rose()andgrid.pattern_text()now “clip” their boundary using an “alpha mask” rather than a “clipping path”. Now use the argumentuse_R4.1_masks, the global optionggpattern_use_R4.1_masks, or the global optionggpattern_use_R4.1_featuresto toggle on/off the R 4.1 alpha mask feature instead of using theuse_R4.1_clippingargument or the global optionggpattern_use_R4.1_clippingas before (the latter continue to toggle on/off the R 4.1 clipping path feature inclippingPathGrob()).
New Features
-
alphaMaskGrob()is a function that (alpha) masks one grob by using a second grob to specify the (alpha) mask.- If
use_R4.1_masksisTRUEwe simply use the new R 4.1 (alpha) masks feature. - If
use_R4.1_masksisFALSEwe generate agrid::rasterGrob()approximation. - If
use_R4.1_masksisNULLtry to guess an appropriate choice. - The default for
use_R4.1_maskscan be set byoptions("ggpattern_use_R4.1_masks").
- If
Bug fixes and minor improvements
-
guess_has_R4.1_features()now returnsTRUEfor theragg::agg_jpeg(),ragg::agg_ppm(), andragg::agg_tiff()devices ifpackageVersion("ragg") >= '1.2.0'. It also returnsTRUEforsvglite::svglite()ifpackageVersion("svglite") >= '2.1.0'. -
clippingPathGrob()will now consistently - as previously documented - useragg::agg_png()as the defaultpng_devicegraphics device if it is available anduse_R4.1_clippingisFALSE. -
grid.pattern_image()should no longer throw an inscrutableError in magick_image_readpath… error on certain platforms such as Windows (#47).
gridpattern v0.4.0
CRAN release: 2022-01-12
New Features
-
guess_has_R4.1_features()is now an exported function. It guesses whether the “active” graphic devices supports the new R 4.1 graphics features and returnsTRUEorFALSE.
Bug fixes and minor improvements
-
grid.pattern_polygon_tiling()now supports the “elongated_triangular”type(#48). “geometry” patterns now support a “elongated_triangle”gridvalue. -
guess_has_R4.1_features()now returnsTRUEfor theragg::agg_png()andragg::agg_supertransparent()devices ifpackageVersion("ragg") >= '1.2.0'. It now also returnsTRUEfor thegrDevices::bmp(type = "cairo"),grDevices::cairo_ps(),grDevices::jpeg(type = "cairo"), andgrDevices::tiff(type = "cairo")devices ifgetRversion() >= '4.1.0'.
gridpattern v0.3.1
CRAN release: 2021-12-02
New Features
The following package option
ggpattern_rescan now be set byoptions(). It controls default “raster” image pattern resolution (pixels per inch). Defaults to 72 (pixels per inch).-
grid.pattern_polygon_tiling()now supports the following additional polygon tilingtype’s (#42):-
"rhombille"implements a rhombille tiling of rhombi (#37) -
"tetrakis_square"implements a tetrakis square tiling of isosceles right triangles (#38) -
"2*.2**.2*.2**"implements a polygon tiling made of rhombi. -
"2**.3**.12*"implements a polygon tiling made of rhombi, triangles, and twelve-pointed stars. -
"3.3.3.3**"implements a polygon tiling made of triangles. -
"3.3*.3.3**"implements a regular (star) polygon tiling made of triangles and three-pointed stars. -
"3.3.3.12*.3.3.12*"implements a regular (star) polygon tiling made of triangles and twelve-pointed starts. -
"3.3.8*.3.4.3.8*"implements a regular (star) polygon tiling of triangles, squares, and eight-pointed stars. -
"3.3.8*.4**.8*"implements a regular (star) polygon tiling made of triangles, four-pointed stars, and eight-pointed stars. -
"3.4.6.3.12*"implements a regular (star) polygon tiling made of triangles, squares, hexagons, and twelve-pointed stars. -
"3.4.8.3.8*"implements a regular (star) polygon tiling of triangles, squares, octagons, and eight-pointed stars. -
"3.6*.6**"implements a regular (star) polygon tiling made of triangles and six-pointed stars. -
"4.2*.4.2**"implements a polygon tiling made of squares and rhombi. -
"4.4*.4**"implements a regular (star) polygon tiling made of squares and four-pointed stars. -
"4.6.4*.6"implements a regular (star) polygon tiling made of squares, hexagons, and four-pointed stars. -
"4.6*.4.6*.4.6*"implements a regular (star) polygon of squares and six-pointed stars. -
"4.8*.4**.8*"implements a polygon tiling of squares and eight-pointed stars. -
"6.6*.6.6*"implements a regular (star) polygon of hexagons and six-pointed stars. -
"8.4*.8.4*"implements a regular (star) polygon of octagons and four-pointed stars. -
"9.3.9.3*"implements a regular (star) polygon of triangles, nonagons, and three-pointed stars. -
"12.3*.12.3*"implements a regular (star) polygon tiling made of dodecagons and three-pointed stars. -
"12.12.4*"implements a regular (star) polygon tiling made of dodecagons and four-pointed stars. -
"18.18.3*"implements a regular (star) polygon tiling made of eighteen-sided polygons and three-pointed stars.
-
grid.pattern_regular_polygon()now supports a"tetrakis_left"shapeand"tetrakis_right"shapewhich both draw an isosceles right triangle (one oriented left and one oriented right) as well as a"rhombille_rhombus"shape which draws a rhombus. These are non-regular polygons intended to help produce tetrakis square and rhombille polygon tilings.
Bug fixes and minor improvements
-
star_angle()andstar_scale()now handle then_vertices == 2case (a “two-pointed star” polygon is a rhombus). - Fixes
grid.pattern_gradient()whenuse_R4.1_gradients=TRUEto better match behavior whenuse_R4.1_gradients=FALSE. - Now allows alpha values to be specified within the
fill(andfill2) colour strings forgridpattern_plasma()andgridpattern_gradient()(whenuse_R4.1_gradients=FALSE). - In
pattern_square()for the “horizontal” and “vertical” types the value1Lis now guaranteed to be in the center of the pattern (#46).
gridpattern v0.2.1
CRAN release: 2021-07-17
Breaking Changes
- “array” patterns no longer set a minimum 12 pixel image width and/or height. In particular, they can now have a zero pixel image width and/or height (in which case the array pattern returns a
grid::nullGrob()). - “array” patterns no longer reduces the number of requested pixels when
legend = TRUE.
New Features
-
Supports the following new patterns:
- “rose” (curve)
grid.pattern_rose()(#43) - “text”
grid.pattern_text()(#40) - “wave”
grid.pattern_wave()which supports “sine” and “triangle”typewaves (#16)
- “rose” (curve)
names_patternis a new character vector of supported (builtin) patterns.-
clippingPathGrob()is a function that clips one grob according to clipping path set by a second grob.- If
use_R4.1_clippingisTRUEwe simply use the new R 4.1 clipping path feature - If
use_R4.1_clippingisFALSEwe generate agrid::rasterGrob()approximation - If
use_R4.1_clippingisNULLtry to guess an appropriate choice. - The default for
use_R4.1_clippingcan be set byoptions("ggpattern_use_R4.1_clipping")
- If
-
grid.pattern_gradient()now supports the argumentuse_R4.1_gradients- If
TRUEuse the new R 4.1 gradient feature - If
FALSEuse arasterGrobapproximation (old behaviour) - If
NULLtry to guess an appropriate choice. - The default for
use_R4.1_gradientscan be set byoptions("ggpattern_use_R4.1_gradients")
- If
-
The following package options can now be set by
options():-
ggpattern_use_R4.1_clippingIfTRUEuse the grid clipping path feature introduced in R v4.1.0. IfFALSEdo arasterGrobapproximation of the clipped pattern. Currently used byclippingPathGrob(),grid.pattern_rose(),grid.pattern_text(), and available for custom patterns. -
ggpattern_use_R4.1_featuresSet the default for all the otherggpattern_use_R4.1_*options arguments. -
ggpattern_use_R4.1_gradientsIfTRUEuse the grid gradient feature introduced in R v4.1.0. IfFALSEdo arasterGrobapproximation of the gradient pattern. Currently used bygrid.pattern_gradient()and available for custom patterns. -
ggpattern_use_R4.1_masksIfTRUEuse the grid mask feature introduced in R v4.1.0. Currently unused by this package but available for custom patterns. -
ggpattern_use_R4.1_patternsIfTRUEuse the grid pattern feature introduced in R v4.1.0. Currently unused by this package but available for custom patterns.
-
Bug fixes and minor improvements
-
grid.pattern()now throws an error if there is a non-unique pattern name (set byoptions("ggpattern_geometry_funcs")and/oroptions("ggpattern_array_funcs")). - Fixes an error when catching a {magick} image reading error for some array patterns.
gridpattern v0.1.2
CRAN release: 2021-06-17
grid.pattern()draws a specified “pattern” to the active graphics device whilepatternGrob()returns a “pattern” (grid) grob.-
Supports the following original patterns:
- “pch”
grid.pattern_pch() - “polygon_tiling”
grid.pattern_polygon_tiling()(#13) - “regular_polygon”
grid.pattern_regular_polygon()(#20) - “weave”
grid.pattern_weave()(#12)
- “pch”
-
Supports the following patterns from ggpattern:
- “ambient”
grid.pattern_ambient() - “circle”
grid.pattern_circle()(#5) - “crosshatch”
grid.pattern_crosshatch()(#4) - “gradient”
grid.pattern_gradient()(#8) - “image”
grid.pattern_image()(#9) - “magick”
grid.pattern_magick()(#6) - “none”
grid::null() - “placeholder”
grid.pattern_placeholder()(#10) - “plasma”
grid.pattern_plasma()(#7) - “stripe”
grid.pattern_stripe()(#3) - Custom ggpattern geometry-based patterns (#1)
- Custom ggpattern array-based patterns (#2)
Enhancements made to the ggpattern patterns provided by this package:
Resolution of “array” patterns is now settable by new “pattern_res”. Defaults to 72 pixels per inch but sets a minimum 12 pixel image width and/or height.
Default for “pattern_alpha” is now
NA_real_(preserve existing alpha transparency) instead of1(set to fully opaque).grid.pattern_ambient()pattern supports all arguments of the six ambient “noise” functions.-
grid.pattern_circle()has several enhancements:- Allows use of the argument
xoffsetandyoffset(#22) - Allows use of arguments
grid,type, andsubtypeto customize the pattern arrangement. - Use of multiple
fillcolors now produces a more attractive pattern. - Use of
densitygreater than1will now sometimes give an attractive result (#17). - Uses sf to clip circles to boundary instead of gridGeometry
- Allows use of the argument
grid.pattern_crosshatch()allows using the argumentfill2to set different fill color(s) for the “over” crosshatch lines (#14).xoffset,yoffset, andspacingare now interpreted as “snpc” units andgrid.pattern_stripe()andgrid.pattern_crosshatch()now allow using the argumentgridto tweak placement of lines so that they now match the placement of circles fromgrid.pattern_circle()and polygons fromgrid.pattern_regular_polygon()(#24).The center point of the geometry “grid” now matches the center of the viewport.
- “ambient”
mean_col()is a utility function that computes an “average” color (#21)star_scale()andstar_angle()are utility functions for converting between regular star polygon parameterizations (#39).pattern_hex()returns an integer matrix indicating placement of multiple colors (or other graphical elements) on a hex grid. Supports types listed inhex_names.pattern_square()returns an integer matrix indicating placement of multiple colors (or other graphical elements) on a rectangular grid. Supports types listed insquare_names.pattern_weave()returns a logical matrix indicating where the warp lines should “up” for a specified weave pattern type and subtype. Supports weaves listed inweave_names. In particular supports “irregular matt” and “elongated twill” family of weave patterns including “zig-zag” and “herringbone” variations.