Description Usage Arguments Examples
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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
)
|
img |
The image, in magick format |
x |
Unit object specifying x position of rectangle |
y |
Unit object specifying y position of rectangle |
width |
Unit object specifying the rectangle width |
height |
Unit object specifying the rectangle height |
just |
Vector of two numeric values specifying horizontal and vertical
justification of rectangle relative to |
img_width |
Unit object specifying the width of the texture image.
If |
img_height |
Unit object specifying the height of the texture image.
If |
nrow |
Number of image rows. If |
ncol |
Number of image columns. If |
hjust |
Horizontal justification of images. |
vjust |
Vertical justification of images. |
fill |
Fill color for rectangle. |
color |
Border color for rectangle. |
lty |
Line type for border. |
lwd |
Line width for border. |
clip |
Should images be clipped to rectangle extent? |
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. |
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). |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.