% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/texture-grob.R
\name{texture_grob}
\alias{texture_grob}
\alias{makeContent.texture_grob}
\title{Draw rectangle filled with a texture image}
\usage{
texture_grob(
  img,
  x = unit(0.5, "npc"),
  y = unit(0.5, "npc"),
  width = unit(1, "npc"),
  height = unit(1, "npc"),
  just = c(0, 0),
  img_width = unit(1, "null"),
  img_height = NA,
  nrow = NA,
  ncol = NA,
  hjust = 0.5,
  vjust = 0,
  fill = "#E8E8E8",
  color = "#000000",
  lty = 1,
  lwd = 1,
  clip = "on",
  repmax = 500,
  interpolate = TRUE
)
}
\arguments{
\item{img}{The image, in magick format}

\item{x}{Unit object specifying x position of rectangle}

\item{y}{Unit object specifying y position of rectangle}

\item{width}{Unit object specifying the rectangle width}

\item{height}{Unit object specifying the rectangle height}

\item{just}{Vector of two numeric values specifying horizontal and vertical
justification of rectangle relative to \code{x} and \code{y}.}

\item{img_width}{Unit object specifying the width of the texture image.
If \code{"null"} unit is used, then the image width is calculated relative
to the rectangle width.}

\item{img_height}{Unit object specifying the height of the texture image.
If \code{"null"} unit is used, then the image height is calculated relative
to the rectangle height.}

\item{nrow}{Number of image rows. If \code{NA}, is calculated automatically
from the available space.}

\item{ncol}{Number of image columns. If \code{NA}, is calculated automatically
from the available space.}

\item{hjust}{Horizontal justification of images.}

\item{vjust}{Vertical justification of images.}

\item{fill}{Fill color for rectangle.}

\item{color}{Border color for rectangle.}

\item{lty}{Line type for border.}

\item{lwd}{Line width for border.}

\item{clip}{Should images be clipped to rectangle extent? \code{"on"} means
yes, \code{"off"} means no.}

\item{repmax}{Maximum number of image repetitions. By default set to 500.
This is a safety check against bad parameter settings that might create
hundreds of thousands of images or more.}

\item{interpolate}{A logical value indicating whether to linearly interpolate the image
(the alternative is to use nearest-neighbour interpolation, which gives a more blocky result).}
}
\description{
A texture grob is a grid grob that draws a rectangle filled with an image. The image will
be tiled if it is not large enough to fill the entire space of the rectangle.
}
\examples{
img <- magick::image_read("https://jeroen.github.io/images/Rlogo.png")

grid.newpage()
tg1 <- texture_grob(
  img,
  x = unit(.2, "npc"), y = unit(.05, "npc"),
  width = unit(.1, "npc"), height = unit(.9, "npc"),
  img_width = unit(.5, "in"), ncol = 1
)
tg2 <- texture_grob(
  img,
  x = unit(.5, "npc"), y = unit(.05, "npc"),
  width = unit(.3, "npc"), height = unit(.6, "npc"),
  img_width = unit(.5, "in"), ncol = 1
)

grid.draw(tg1)
grid.draw(tg2)
}
