Uses Bresenham's algorithm to draw lines. No antialiasing.

nr_line(nr, x1, y1, x2, y2, color = "black", linewidth = 1)

Arguments

nr

nativeRaster

x1, y1, x2, y2

Vectors of coordinates of endpoints of line

color

Color as a character string. Either a standard R color (e.g. 'blue', 'white') or a hex color of the form #rrggbbaa, #rrggbb, #rgba or #rgb

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 <- 20
nr <- nr_new(N, N, 'grey80')
nr_line(nr, x1 = c(0, N-1), y1 = c(0, 0), x2 = c(N-1, 0), y2 = c(N-1, N-1), 
        color = c('red', 'black'))
plot(nr)