Skip to content

Commit

Permalink
allow image objects in image column
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Sep 28, 2018
1 parent efd845b commit 796ab08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions DESCRIPTION
Expand Up @@ -26,5 +26,6 @@ Collate:
'geom-textured-bar.R'
'geom-isotype-bar.R'
'ggtextures.R'
'scale-image.R'
'texture-grob.R'
'utils.R'
13 changes: 12 additions & 1 deletion R/geom-textured-rect.R
Expand Up @@ -92,7 +92,7 @@ GeomTexturedRect <- ggproto("GeomTexturedRect",
}

texture_grob(
magick::image_read(image),
get_raster_image(image),
x = unit(xmin, "native"), y = unit(ymax, "native"),
width = unit(xmax - xmin, "native"),
height = unit(ymax - ymin, "native"),
Expand All @@ -117,6 +117,17 @@ GeomTexturedRect <- ggproto("GeomTexturedRect",
draw_key = draw_key_polygon
)

get_raster_image <- function(img) {
UseMethod("get_raster_image", img)
}

get_raster_image.default <- function(img) {
magick::image_read(img)
}

`get_raster_image.magick-image` <- function(img) {
img
}

# sources of free textures to use:
# https://www.hypergridbusiness.com/free-seamless-textures/
Expand Down
1 change: 1 addition & 0 deletions R/scale-image.R
@@ -0,0 +1 @@
#

0 comments on commit 796ab08

Please sign in to comment.