The returned hook opens mypaint_device() before chunk evaluation and
injects the generated PNG files afterward. This avoids knitr's normal plot
replay path, which does not preserve device-local style changes such as
set_hand() and set_brush().
Arguments
- ...
Default arguments passed through to
mypaint_device()when the hook opens a device. Chunk-specific overrides can be supplied in the chunk optionmypaint.argsas a named list. Because these arguments are applied when the device opens, use this hook ormypaint.argsto set chunk defaults;set_brush()andset_hand()still work within the chunk after the device is open.
Details
Register it with knitr::knit_hooks$set(mypaint = knitr_mypaint_hook(...))
and then enable it for chunks with mypaint = TRUE. Chunks should also set
fig.keep = "none" and fig.ext = "png". If a chunk explicitly sets
dev=, the hook is skipped and knitr's normal device handling is used.
Examples
if (requireNamespace("knitr", quietly = TRUE)) {
hook <- knitr_mypaint_hook(brush = "deevad/2B_pencil")
print(is.function(hook))
}
#> [1] TRUE