Skip to content

Commit

Permalink
refactor!: Default "placeholder" type now "bear"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
trevorld committed Apr 22, 2024
1 parent 4be21fa commit f3e86c3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 25 deletions.
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
54 changes: 31 additions & 23 deletions R/pattern-array-placeholder.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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'")
Expand Down
2 changes: 1 addition & 1 deletion R/utils-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion man/grid.pattern_placeholder.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3e86c3

Please sign in to comment.