This is useful as a way of positioning sprites or icons in an image.

nr_blit(
  nr,
  x,
  y,
  src,
  x0 = 1L,
  y0 = 1L,
  w = NULL,
  h = NULL,
  respect_alpha = TRUE
)

Arguments

nr

native raster to copy into

x, y

Where in nr to place the sprite. These values must be vectors of the same length. If the length is greater than 1, then the sprite will be pasted into nr at multiple locations. Note that the origin of nativeraster images is the bottom-left where the coordinates are (1, 1).

src

native raster to copy from

x0, y0

start coordiates within src

w, h

size within src

respect_alpha

Should the alpha channel be respected when blitting? Default: TRUE. If FALSE, then contents will be blindly overwritten which can be much much faster. If the src has an any transparent pixels, respect_alpha = TRUE is probably the correct setting.

Value

nativeRaster

Examples

nr <- nr_new(50, 50, 'grey80')
nr_blit(nr, x = 1, y = 1, src = deer, x0 = 1, y0 = 129, w = 32, h = 32)
plot(nr)