The source and destination nativeRaster
images must have the same dimensions.
nr_copy_into(dst, src, mask = NULL, color = "black", invert = FALSE)
Source and destination nativeRaster
images
Optional nativeRaster image to use as a mask. Default: NULL (no mask)
Copy the source pixels into the destination where the mask
matches this color. See also the invert
argument.
Invert masking so that pixels are copied where the mask does not match the specified color. Default: FALSE
The 'dst' nativeRaster
If the nativeRaster
images are of different sizes or alpha blending is
required, use the nr_blit()
function.
nr1 <- nr_new(200, 100, 'hotpink')
nr2 <- nr_new(200, 100, 'green')
nr_copy_into(nr1, nr2)
plot(nr1)
# Copy with mask
logo <- png::readPNG(system.file("img", "Rlogo.png", package="png"), native = TRUE)
src <- nr_duplicate(logo)
dst <- nr_duplicate(logo)
nr_fill(src, 'hotpink')
nr_copy_into(dst, src, mask = logo, col = 0L, invert = TRUE)
plot(dst, T)