These functions are used to globally set a mask which determines where
pixels are affected by drawing functions.
nr_mask_begin(nr, mask)
nr_mask_end(nr)
Arguments
- nr
native raster image
- mask
native raster image to use as mask. Must be the same size as
nr.
Value
Invisibly return the original native raster image which has been
modified in-place
Details
Drawing operations between
nr_mask_begin() and nr_mask_end() calls will only affect pixels
where the mask is not transparent.
Examples
if (FALSE) { # interactive()
mask <- deer[[1]] |> nr_resize(600, 400)
plot(mask)
img <- nr_new_from(mask)
nr_mask_begin(img, mask = mask)
nr_circle(img, 300, 200, 200, fill = 'blue', color = 'black')
nr_circle(img, 350, 200, 100, fill = 'darkgreen', color = 'black')
nr_mask_end(img)
plot(img)
}