R/nr-blit.R
nr_blit.RdCopy a whole image, or subset of an image, into the destination image and configure the angle and size of the copied image.
nr_blit(
dst,
src,
x,
y,
xsrc = 0L,
ysrc = 0L,
w = -1L,
h = -1L,
hjust = 0.5,
vjust = 0.5,
angle = 0,
scale = 1,
use_alpha = TRUE
)source and destination native raster images
Location in dst to place the src image. These values must
be vectors of the same length. If the length is greater than 1, then
the src will be pasted into dst at multiple locations.
Upper-left coordinates of the bounding box within the src
image to copy. Default: (0, 0)
Width and height of the bounding box within the src to copy.
If size is negative, then the actual width/height of
the src is used. Default: (-1, -1)
specify horizontal and vertical justification of the
handle on the src image to be placed at (x, y) within
the dst image.
Default (0, 0) is to use the top-left corner of the image as the
handle.
Use (0.5, 0.5) to centre the src image at the dst
location (x, y)
Rotation angle (clockwise) in radians. Default: 0
Zoom factor. Default: 1
Use alpha channel when drawing? Logical. Default: TRUE
Invisibly return the supplied dst native raster image which was been
modified in-place
Other blitting functions:
nr_blit_bulk()
nr <- nr_new(50, 50, 'grey80')
nr_blit(dst = nr, src = deer[[1]], x = 25, y = 25)
plot(nr)
nr <- nr_new(300, 200, 'grey80')
sq <- nr_new(20, 20, 'darkblue')
nr_blit(nr, src = sq, x = 100, y = 100, angle = pi/3, scale = 5)
plot(nr)
nr <- nr_new(800, 600, 'grey80')
sq <- fastpng::read_png(system.file("image/deer-1.png", package="nara"), type = 'nativeraster')
nr_blit(nr, src = sq, x = 300, y = 240, angle = pi/2, scale = 1)
plot(nr)