From f3e86c32860e282a0065e17b4498f7230765fa92 Mon Sep 17 00:00:00 2001 From: "Trevor L. Davis" Date: Sun, 21 Apr 2024 23:56:47 -0700 Subject: [PATCH] refactor!: Default "placeholder" type now "bear" BREAKING CHANGES: * The default `type` for the "placeholder" pattern is now "bear" instead of "kitten". Explicitly set `type = "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 closes #73 --- NEWS.md | 13 ++++++++ R/pattern-array-placeholder.R | 54 +++++++++++++++++++-------------- R/utils-params.R | 2 +- man/grid.pattern_placeholder.Rd | 2 +- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/NEWS.md b/NEWS.md index 52d5947..672396c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,19 @@ gridpattern v1.2.0 (development) ================================ +Breaking Changes +---------------- + +* The default `type` for the "placeholder" pattern + is now "bear" instead of "kitten". + Explicitly set `type = "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()` wraps `patternGrob()` to return a `grid::pattern()` fill object (#70). * The "geometry" patterns (e.g. "circle", "stripe", etc.) now allow diff --git a/R/pattern-array-placeholder.R b/R/pattern-array-placeholder.R index ed5d512..c9b1392 100644 --- a/R/pattern-array-placeholder.R +++ b/R/pattern-array-placeholder.R @@ -19,7 +19,7 @@ #' @seealso [reset_image_cache()] resets the image cache used by [grid.pattern_image()] and `grid.pattern_placeholder()`. #' @export grid.pattern_placeholder <- function(x = c(0, 0, 1, 1), y = c(1, 0, 0, 1), id = 1L, ..., - type = "kitten", alpha = gp$alpha %||% NA_real_, + type = "bear", alpha = gp$alpha %||% NA_real_, aspect_ratio = 1, key_scale_factor = 1, res = getOption("ggpattern_res", 72), default.units = "npc", name = NULL, gp = gpar(), draw = TRUE, vp = NULL) { @@ -34,11 +34,19 @@ grid.pattern_placeholder <- function(x = c(0, 0, 1, 1), y = c(1, 0, 0, 1), id = #' @rdname grid.pattern_placeholder #' @export names_placeholder <- c( - "kitten", "kittenbw", "picsum", "picsumbw", "murray", "murraybw", - "cage", "cagebw", "bear", "bearbw", "seagal", "seagalbw", "placeholderbw", - "placeholder", "dummybw", "dummy", "flickr", "flickrbw", "beard", - "beardbw", "lorempixel", "lorempixelbw", "placeimg", "placeimgbw", - 'keanu', 'keanubw' + "bear", "bearbw", + "beard", "beardbw", + "cage", "cagebw", + "dummybw", "dummy", + "flickr", "flickrbw", + "keanu", "keanubw", + "kitten", "kittenbw", + "lorempixel", "lorempixelbw", + "murray", "murraybw", + "picsum", "picsumbw", + "placeholder", "placeholderbw", + "placeimg", "placeimgbw", + "seagal", "seagalbw" ) #' Fetch a placeholder image of the correct dimensions @@ -71,32 +79,32 @@ fetch_placeholder_img <- function(width = 100, height = 100, type = 'kitten') { img_url <- switch( type, - kitten = glue("https://placekitten.com/{width}/{height}"), - kittenbw = glue("https://placekitten.com/g/{width}/{height}"), - picsum = glue("https://picsum.photos/{width}/{height}"), - picsumbw = glue("https://picsum.photos/{width}/{height}?grayscale"), - murray = glue("http://www.fillmurray.com/{width}/{height}"), - murraybw = glue("http://www.fillmurray.com/g/{width}/{height}"), - cage = glue("https://www.placecage.com/{width}/{height}"), - cagebw = glue("https://www.placecage.com/g/{width}/{height}"), bear = glue("https://placebear.com/{width}/{height}"), bearbw = glue("https://placebear.com/g/{width}/{height}"), - seagal = glue("https://www.stevensegallery.com/{width}/{height}"), - seagalbw = glue("https://www.stevensegallery.com/g/{width}/{height}"), - placeholderbw = , - placeholder = glue("https://via.placeholder.com/{width}x{height}.png"), - dummybw = , + beard = glue("http://placebeard.it/{width}/{height}"), + beardbw = glue("http://placebeard.it/g/{width}/{height}"), + cage = glue("https://www.placecage.com/{width}/{height}"), + cagebw = glue("https://www.placecage.com/g/{width}/{height}"), dummy = glue("https://dummyimage.com/{width}x{height}"), + dummybw = , flickr = glue("https://loremflickr.com/{width}/{height}"), flickrbw = glue("https://loremflickr.com/g/{width}/{height}/all"), - beard = glue("http://placebeard.it/{width}/{height}"), - beardbw = glue("http://placebeard.it/g/{width}/{height}"), + keanu = glue("https://placekeanu.com/{width}/{height}"), + keanubw = glue("https://placekeanu.com/{width}/{height}/g"), + kitten = glue("https://placekitten.com/{width}/{height}"), + kittenbw = glue("https://placekitten.com/g/{width}/{height}"), lorempixel = glue("http://lorempixel.com/{width}/{height}"), lorempixelbw = glue("http://lorempixel.com/g/{width}/{height}"), + murray = glue("http://www.fillmurray.com/{width}/{height}"), + murraybw = glue("http://www.fillmurray.com/g/{width}/{height}"), + picsum = glue("https://picsum.photos/{width}/{height}"), + picsumbw = glue("https://picsum.photos/{width}/{height}?grayscale"), + placeholder = glue("https://via.placeholder.com/{width}x{height}.png"), + placeholderbw = , placeimg = glue("http://placeimg.com/{width}/{height}/any"), placeimgbw = glue("http://placeimg.com/{width}/{height}/any/grayscale"), - keanu = glue("https://placekeanu.com/{width}/{height}"), - keanubw = glue("https://placekeanu.com/{width}/{height}/g"), + seagal = glue("https://www.stevensegallery.com/{width}/{height}"), + seagalbw = glue("https://www.stevensegallery.com/g/{width}/{height}"), { # warn("fetch_placeholder_image_as_array(): Unknown pattern_type (", type, ") ", # "using 'kitten'") diff --git a/R/utils-params.R b/R/utils-params.R index e898079..6dd1b49 100644 --- a/R/utils-params.R +++ b/R/utils-params.R @@ -101,7 +101,7 @@ default_pattern_type <- function(pattern) { switch(pattern, ambient = "simplex", image = "fit", - placeholder = "kitten", + placeholder = "bear", polygon_tiling = "square", magick = "hexagons", wave = "triangle", diff --git a/man/grid.pattern_placeholder.Rd b/man/grid.pattern_placeholder.Rd index 069e6d2..6500ee2 100644 --- a/man/grid.pattern_placeholder.Rd +++ b/man/grid.pattern_placeholder.Rd @@ -14,7 +14,7 @@ grid.pattern_placeholder( y = c(1, 0, 0, 1), id = 1L, ..., - type = "kitten", + type = "bear", alpha = gp$alpha \%||\% NA_real_, aspect_ratio = 1, key_scale_factor = 1,