Draw rectangles on a nativeRaster image

nr_rect(
  nr,
  x,
  y,
  w,
  h,
  fill = "black",
  color = NA,
  hjust = 0,
  vjust = 0,
  linewidth = 1
)

Arguments

nr

nativeRaster

x, y

coordinates of lower left corner of rectangle. [vector]

w, h

width and height of rectangle. [vector]

fill

interior fill color [vector]

color

outline color. Default: NA. [vector]

hjust, vjust

specify horizontal and vertical justification of the src image. e.g. hjust = vjust = 0 the blitting starts at the top-left of the image. Use hjust = vjust = 0.5 to treat the centre of the src_ as the blitting origin. Default (0, 0)

linewidth

Line linewidth. Default: 1. If linewidth = 1 then a naive version of Bresenham is used to draw the points. If linewidth is greater than 1, then the line is convert to a triangle strip and rendered as polygons.

Value

Original nativeRaster modified in-place

Examples

N <- 200
nr <- nr_new(N, N, 'grey80')
nr_rect(nr, x = c(0, N/2 - 1), y = c(0, N/2 - 1), w = N/2, h = N/4, 
        fill = 'blue', color = c('red', 'green'), linewidth = 17)
plot(nr, TRUE)