% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nr-blit.R
\name{nr_blit}
\alias{nr_blit}
\title{Copy a native raster image into another at an arbitrary location, scale and rotation}
\usage{
nr_blit(
  dst,
  src,
  x,
  y,
  xsrc = 0L,
  ysrc = 0L,
  w = -1L,
  h = -1L,
  hjust = 0.5,
  vjust = 0.5,
  angle = 0,
  scale = 1,
  use_alpha = TRUE
)
}
\arguments{
\item{dst, src}{source and destination native raster images}

\item{x, y}{Location in \code{dst} to place the \code{src} image. These values must
be vectors of the same length.  If the length is greater than 1, then
the \code{src} will be pasted into \code{dst} at multiple locations.}

\item{xsrc, ysrc}{Upper-left coordinates of the bounding box within the \code{src}
image to copy.  Default: (0, 0)}

\item{w, h}{Width and height of the bounding box within the \code{src} to copy.
If size is negative, then the actual width/height of
the src is used. Default: (-1, -1)}

\item{hjust, vjust}{specify horizontal and vertical justification of the 
handle on the \code{src} image to be placed at \code{(x, y)} within 
the \code{dst} image.
Default (0, 0) is to use the top-left corner of the image as the 
handle.
Use (0.5, 0.5) to centre the \code{src} image at the \code{dst} 
location \code{(x, y)}}

\item{angle}{Rotation angle (clockwise) in radians. Default: 0.
If this is a vector, then the \code{src} will be pasted into the
\code{dst} at multiple angles.}

\item{scale}{Zoom factor. Default: 1.  IF this is a vector, then the \code{src}
will be pasted into \code{dst} at multiple scales.}

\item{use_alpha}{Use alpha channel when drawing? Logical. Default: TRUE}
}
\value{
Invisibly return the supplied \code{dst} native raster image which was been
        modified in-place
}
\description{
Copy a whole image, or subset of an image, into the destination image and 
configure the angle and size of the copied image.
}
\details{
This operation is vectorised such that a single \code{src} image can be 
pasted multiple times into the \code{dst} image with varying location, 
angle and scale.
}
\examples{
nr <- nr_new(50, 50, 'grey80')
nr_blit(dst = nr, src = deer[[1]], x = 25, y = 25)
plot(nr)

nr <- nr_new(300, 200, 'grey80')
sq <- nr_new(20, 20, 'darkblue')
nr_blit(nr, src = sq, x = 100, y = 100, angle = pi/3, scale = 5)
plot(nr)

nr <- nr_new(800, 600, 'grey80')
sq <- fastpng::read_png(system.file("image/deer-1.png", package="nara"), type = 'nativeraster')
nr_blit(nr, src = sq, x = 300, y = 240, angle = pi/2, scale = 1)
plot(nr)
}
\seealso{
Other blitting functions: 
\code{\link{nr_blit_multi}()}
}
\concept{blitting functions}
