--- title: "Hand demo" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Hand Demo} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} library(mypaintr) knitr::knit_hooks$set(mypaint = knitr_mypaint_hook(res = 288)) knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.ext = "png", fig.width = 7, fig.height = 5, out.width = "100%", fig.keep = "none", mypaint = TRUE ) ``` ```{r} plot_with_hand <- function(...) { null <- length(list(...)) &&is.null(list(...)[[1]]) title <- deparse(substitute(list(...))) title <- if (! null) { sub("list\\((.*)\\)", "human_hand(\\1)", title) } else { "NULL" } plot.new() plot.window(c(0, 10), c(0, 10)) title(title) set_brush(NULL) if (null) hand <- NULL else hand <- human_hand(seed = 1, ...) set_hand(hand) rect(1, 1, 4, 4) draw_rough_rect(6, 6, 9, 9, col = "green4", hand = hand) draw_rough_rect(1, 6, 4, 9, col = "darkred", fill_pattern = zigzag(), hand = hand) draw_rough_rect(6, 1, 9, 4, lwd = 2, border = "navy", col = "slateblue3", fill_pattern = jumble(density = 12), hand = hand) arrows(1, 5, 9, 5, lwd = 6) } ``` ```{r} plot_with_hand(NULL) ``` ```{r} plot_with_hand() ``` ```{r} plot_with_hand(bow = 0) ``` ```{r} plot_with_hand(wobble = 0) ``` ```{r} plot_with_hand(multi_stroke = 2) ``` ```{r} plot_with_hand(width_jitter = 0.24, multi_stroke = 2) ``` ```{r} plot_with_hand(endpoint_jitter = 0) ``` ```{r} plot_with_hand(endpoint_jitter = 0.02) ``` # Pressure on the default device ```{r} plot_with_hand(pressure = pressure_flat(0.5)) ``` ```{r} plot_with_hand(pressure = pressure_smooth()) ``` # Pressure using `mypaint_device()` and brushes ```{r, mypaint=TRUE, fig.keep="none"} set_brush("classic/pen") plot_with_hand(pressure = pressure_flat()) ``` ```{r, mypaint=TRUE, fig.keep="none"} set_brush("classic/pen") plot_with_hand(pressure = pressure_smooth()) ``` ```{r, mypaint=TRUE, fig.keep="none"} set_brush("ramon/Marker") plot_with_hand(pressure = pressure_flat()) ``` ```{r, mypaint=TRUE, fig.keep="none"} set_brush("ramon/Marker") plot_with_hand(pressure = pressure_smooth()) ``` ```{r, mypaint=TRUE, fig.keep="none"} set_brush("ramon/Marker") plot_with_hand(pressure = pressure_human()) ```