nr_mask_begin: Start/end region of masked drawing

View source: R/nr-mask.R

nr_mask_beginR Documentation

Start/end region of masked drawing

Description

These functions are used to globally set a mask which determines where pixels are affected by drawing functions.

Usage

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.

Details

Drawing operations between nr_mask_begin() and nr_mask_end() calls will only affect pixels where the mask is not transparent.

Value

Invisibly return the original native raster image which has been modified in-place

Examples


mask <- deer[[1]] |> nr_resize(600, 400)
plot(mask)
nr <- nr_new_from(mask)

nr_mask_begin(nr, mask = mask)
nr_circle(nr, 300, 200, 200, fill = 'blue', color = 'black')
nr_circle(nr, 350, 200, 100, fill = 'darkgreen', color = 'black')
nr_mask_end(nr)

plot(nr)


nara documentation built on May 28, 2026, 5:07 p.m.