% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nr-draw.R
\name{nr_line}
\alias{nr_line}
\title{Draw lines on a native raster image}
\usage{
nr_line(nr, x1, y1, x2, y2, color = "black", linewidth = 1, use_alpha = TRUE)
}
\arguments{
\item{nr}{native raster image}

\item{x1, y1, x2, y2}{Vectors of coordinates of endpoints of line}

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

\item{linewidth}{Line linewidth. Default: 1.  If \code{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.}

\item{use_alpha}{Use alpha channel when drawing? Logical. Default: TRUE}
}
\value{
Invisibly return the supplied native raster image which was been
        modified in-place
}
\description{
Uses Bresenham's algorithm to draw lines. No antialiasing.
}
\examples{
w <- 200
h <- 150
nr <- nr_new(w, h, 'grey80')

N <- 40
nr_line(
  nr,
  x1 = seq(0, 2*w, length.out =  N), y1 = 0,
  x2 = 0, y2 = seq(0, 2 * h, length.out = N),
  color = rainbow(N)
)

plot(nr)

}
