- New pattern "aRtsy" with corresponding
grid.pattern_aRtsy()
with patterns powered by the{aRtsy}
package (#87).
-
grid.pattern_weave()
adds the newunits
parameter that most other "geometry" pattern functions received in gridpattern v1.2.1. -
The "polygon_tiling" pattern should now respect the
units
parameter 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".
-
- The default
type
for 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).
-
patternFill()
wrapspatternGrob()
to return agrid::pattern()
fill object (#70). -
The "geometry" patterns (e.g. "circle", "stripe", etc.) now allow the
fill
to be pattern fills (#67). -
The "geometry" patterns (e.g. "circle", "stripe", etc.) now allow the new
units
parameter to set whichgrid::unit()
to use for the thespacing
,xoffset
, andyoffset
parameters (and for the "wave" pattern also theamplitude
andfrequency
parameters) (#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.R
into your R directory and addinggrDevices
,grid
, andrlang
to theImports
of yourDESCRIPTION
file.
- 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.
- The
wave
pattern no longer quietly and incorrectly ignores thefrequency
parameter. The effective wavelength of the wave pattern is now1 / frequency
instead ofspacing
. Howeverfrequency
will continue to default to1 / spacing
. clippingPathGrob()
can now more efficiently compute arasterGrob()
approximation viaragg::agg_capture()
and forpng_device
functions that support the clipping path feature such aspng(type = "cairo")
(#74).alphaMaskGrob()
can now more efficiently compute arasterGrob()
approximation forpng_device
functions 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.
- "text" pattern example now skipped if ran within certain graphics devices like
pdf()
that can't handle the playing cards Unicode glyphs (#68).
reset_image_cache()
resets the image cache used bygrid.pattern_image()
andgrid.pattern_placeholder()
to store images (#63).
- 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.R
into yourR
directory and addinggrDevices
andutils
to theImports
of yourDESCRIPTION
file. - If
{vdiffr}
has been updated to at least v1.0.6 (released 2023-08-25) thenguess_has_R4.1_features()
should now always correctly guess R4.1 feature support for thesvglite::svglite()
andvdiffr:::svglite()
graphics devices.
- An internal function
convert_polygon_sf_to_polygon_df()
will now be a bit more quiet (throw WARNINGs less often).
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 parameterlinewidth
to 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 usesize
as well. Continue to usesize
(orgp
) to set the fontsize ingrid.pattern_text()
. Bothpattern_linewidth
andpattern_size
will be available for use in custom patterns (#57).
-
Fixes bug with
grid.pattern_image()
withtype = "tile"
(#47). Additionallygrid.pattern_image()
now supportsgravity
argument 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 argumentfeatures
which 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.
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_features
to toggle on/off the R 4.1 alpha mask feature instead of using theuse_R4.1_clipping
argument or the global optionggpattern_use_R4.1_clipping
as before (the latter continue to toggle on/off the R 4.1 clipping path feature inclippingPathGrob()
).
-
alphaMaskGrob()
is a function that (alpha) masks one grob by using a second grob to specify the (alpha) mask.- If
use_R4.1_masks
isTRUE
we simply use the new R 4.1 (alpha) masks feature. - If
use_R4.1_masks
isFALSE
we generate agrid::rasterGrob()
approximation. - If
use_R4.1_masks
isNULL
try to guess an appropriate choice. - The default for
use_R4.1_masks
can be set byoptions("ggpattern_use_R4.1_masks")
.
- If
guess_has_R4.1_features()
now returnsTRUE
for theragg::agg_jpeg()
,ragg::agg_ppm()
, andragg::agg_tiff()
devices ifpackageVersion("ragg") >= '1.2.0'
. It also returnsTRUE
forsvglite::svglite()
ifpackageVersion("svglite") >= '2.1.0'
.clippingPathGrob()
will now consistently - as previously documented - useragg::agg_png()
as the defaultpng_device
graphics device if it is available anduse_R4.1_clipping
isFALSE
.grid.pattern_image()
should no longer throw an inscrutableError in magick_image_readpath
... error on certain platforms such as Windows (#47).
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 returnsTRUE
orFALSE
.
grid.pattern_polygon_tiling()
now supports the "elongated_triangular"type
(#48). "geometry" patterns now support a "elongated_triangle"grid
value.guess_has_R4.1_features()
now returnsTRUE
for theragg::agg_png()
andragg::agg_supertransparent()
devices ifpackageVersion("ragg") >= '1.2.0'
. It now also returnsTRUE
for thegrDevices::bmp(type = "cairo")
,grDevices::cairo_ps()
,grDevices::jpeg(type = "cairo")
, andgrDevices::tiff(type = "cairo")
devices ifgetRversion() >= '4.1.0'
.
-
The package
{magick}
has been downgraded from "Imports" to "Suggests" (#44). You'll need to manually install{magick}
withinstall.packages("magick")
in order to use the following "array" patterns:- "gradient" (but only if
use_R4.1_gradients
isFALSE
) - "image"
- "magick"
- "placeholder"
- "plasma"
- "gradient" (but only if
-
The following package option
ggpattern_res
can 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"
shape
and"tetrakis_right"
shape
which 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.
star_angle()
andstar_scale()
now handle then_vertices == 2
case (a "two-pointed star" polygon is a rhombus).- Fixes
grid.pattern_gradient()
whenuse_R4.1_gradients=TRUE
to 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 value1L
is now guaranteed to be in the center of the pattern (#46).
- "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
.
-
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"type
waves (#16)
- "rose" (curve)
-
names_pattern
is 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_clipping
isTRUE
we simply use the new R 4.1 clipping path feature - If
use_R4.1_clipping
isFALSE
we generate agrid::rasterGrob()
approximation - If
use_R4.1_clipping
isNULL
try to guess an appropriate choice. - The default for
use_R4.1_clipping
can be set byoptions("ggpattern_use_R4.1_clipping")
- If
-
grid.pattern_gradient()
now supports the argumentuse_R4.1_gradients
- If
TRUE
use the new R 4.1 gradient feature - If
FALSE
use arasterGrob
approximation (old behaviour) - If
NULL
try to guess an appropriate choice. - The default for
use_R4.1_gradients
can be set byoptions("ggpattern_use_R4.1_gradients")
- If
-
The following package options can now be set by
options()
:ggpattern_use_R4.1_clipping
IfTRUE
use the grid clipping path feature introduced in R v4.1.0. IfFALSE
do arasterGrob
approximation of the clipped pattern. Currently used byclippingPathGrob()
,grid.pattern_rose()
,grid.pattern_text()
, and available for custom patterns.ggpattern_use_R4.1_features
Set the default for all the otherggpattern_use_R4.1_*
options arguments.ggpattern_use_R4.1_gradients
IfTRUE
use the grid gradient feature introduced in R v4.1.0. IfFALSE
do arasterGrob
approximation of the gradient pattern. Currently used bygrid.pattern_gradient()
and available for custom patterns.ggpattern_use_R4.1_masks
IfTRUE
use the grid mask feature introduced in R v4.1.0. Currently unused by this package but available for custom patterns.ggpattern_use_R4.1_patterns
IfTRUE
use the grid pattern feature introduced in R v4.1.0. Currently unused by this package but available for custom patterns.
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.
-
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
xoffset
andyoffset
(#22) - Allows use of arguments
grid
,type
, andsubtype
to customize the pattern arrangement. - Use of multiple
fill
colors now produces a more attractive pattern. - Use of
density
greater than1
will 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 argumentfill2
to set different fill color(s) for the "over" crosshatch lines (#14). -
xoffset
,yoffset
, andspacing
are now interpreted as "snpc" units andgrid.pattern_stripe()
andgrid.pattern_crosshatch()
now allow using the argumentgrid
to 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.