Stamp a png image

stamp_png(
  x0 = 0,
  y0 = 0,
  png = system.file("img", "Rlogo.png", package = "png"),
  image = png::readPNG(png),
  width = 1,
  height = width * dim(image)[1]/dim(image)[2],
  show.legend = F,
  alpha = 1,
  x0y0 = NULL
)

Arguments

x0

numeric x center of shape, defaults to 0

y0

numeric y center of shape, defaults to 0

png

a string with the path to an image, defaults to R image

image

a numeric array with png red green blue alpha information, defaults to png::readPNG(png)

width

the width that the image should fill, defaults to 1

height

the height that the image should fill, calculated to match aspect ratio based on width

alpha

numeric between 0 and 1 indicating transparency, defaults to 1 fully opaque, zero is fully transparent

x0y0

dataframe indicating center of shapes, where first column is vector for x values and second column is vector for y values, defaults to NULL

Value

Examples

# stamp in plotspace library(ggplot2) ggplot(cars, aes(dist, speed)) + geom_point() + stamp_png(x0 = 5:11*10, y0 = 10, height = 1, width = 10)
# two stamps ggcanvas() + stamp_png() + stamp_png(x0 = 2:3, y0 = 6, width = .95)
#> Scale for 'fill' is already present. Adding another scale for 'fill', which #> will replace the existing scale.
#> Warning: Raster pixels are placed at uneven horizontal intervals and will be shifted. Consider using geom_tile() instead.
# png spokes ggcanvas() + stamp_png()
# tiling pngs needs work ggcanvas() + stamp_png(x0y0 = pos_wrap_png(), alpha = .75)