library(ingrid)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Ensure that images are rendered using a device which understands patterns
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
knitr::opts_chunk$set(dev.args = list(png = list(type = "cairo")))
Creating patterns isn’t drastically different in
ingrid compared to using the grid::pattern()
function.
The changes in ingrid::ig_pattern()
:
extend
is set to ‘repeat’ rather than
‘pad’
library(grid)
library(ingrid)
register_verbose_printing()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create check pattern
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check <- igl_row(
igl_col(
ig_rect(fill = 'black'),
nullGrob()
),
igl_col(
nullGrob(),
ig_rect(fill = 'black')
)
)
grid.newpage(); grid.draw(check)
grob <- ig_circle(fill = ig_pattern(check, width = .cm(3), height = .cm(3)))
grid.newpage(); grid.draw(grob)