name: title class: top, inverse, right background-image: url(https://images.unsplash.com/photo-1593448806592-409752fd816b?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1500&q=80) background-size: cover

{ggstamp}

Photo Credit: Glen Carrie


# This is the recommended set up for flipbooks
# you might think about setting cache to TRUE as you gain practice --- building flipbooks from scratch can be time consuming
knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = T)
library(flipbookr)
library(tidyverse)

r chunk_reveal("my_cars", chunk_options = "fig.width = 8, fig.height = 6", break_type = "user")

library(ggplot2)
library(ggstamp)
ggplot(data = cars) +
  aes(speed, dist) +
  theme_minimal(base_size = 15) + #BREAK
  geom_point() + #BREAK
  stamp_point(color = "darkolivegreen3") + #BREAK
  stamp_point(color = "slateblue", 
              x = c(10, 15), 
              y = c(100, 90)) + #BREAK
  stamp_curve(x = 6, xend = c(10, 14.75),
              y = 9.5, yend = c(95, 85),
              curvature = .2) + #BREAK
  stamp_bubble(fill = "plum2", 
               color = "plum4",
               size = 15,
               x = 5, y = 8) + #BREAK
  stamp_label(label = "This is a stamp",
              x = 20,
              y = 15) + #BREAK
  stamp_text(label = "This\ntoo",
             x = 18,
             y = 110,
             lineheight = .8) + #BREAK
  stamp_segment(x = 20, xend = 18,
                y = 23, yend = 100) + #BREAK
  ggxmean::stamp_normal_dist(
    height = 200, 
    fill = "magenta",
    mean = 14, sd =  2) #BREAK

r chunk_reveal("arrows", chunk_options = "fig.width = 8, fig.height = 6")

ggcanvas() + 
  stamp_point(color = "plum4") +
  stamp_point(x = 1, y = 1, 
              color = "lightsteelblue3",
              size = 35) +
  stamp_arrow(color = "plum4", 
              headlength = .06, 
              type = "closed") + 
  stamp_label(1.5, 2.5, label = "      \n\n\n\n\n", 
              size = 15,
              fill = "lemonchiffon", ) +
  stamp_bubble(2.5, 1.25, size = 100, 
               color = "plum4") + 
  stamp_point(x = c(2,2:4), y = 1:4,
              color = "paleturquoise",
              size = 15) +
  stamp_arrow(y = 2, yend = 1:4, 
              xend = c(2,2:4),
              color = "cadetblue4") + 
  stamp_label(1, 3.5, label = "Stamps!",
              fill = "paleturquoise3") +
  stamp_label(3.2, 1.75, label = "Umm...  \n         ",
              size = 18,
              fill = "thistle") + 
  stamp_label(3.2, 1.75, label = "Umm...  \n Stamps!",
              size = 18,
              fill = "thistle") + 
  theme_void() + 
  stamp_curve(x = .25 + log(1:12), 
              xend = 1.5 + sqrt(1:12),  
              y = 0 + 1:12/20,
              color = "palegreen3",
              yend = 1:12/6, 
              curvature = -.1,
              alpha = 12:1/12)

r chunk_reveal("spoke_ellipse", chunk_options = "fig.width = 8, fig.height = 6")

ggplot(data = faithful) +
  aes(x = eruptions, 
      y = waiting/30 - 1.75,
      color = waiting) +
  coord_equal() +
  scale_color_viridis_c(option = "magma", 
                        direction = -1) +
  geom_point(show.legend = F) +
  stamp_polygon(fill = "plum", 
                size = 0,
                n = 50,
                x0 = 5, y0 = -1) +
  stamp_spoke(angle = pi* 0:32/64,
              color = "paleturquoise4",
              size = 1,
                x = 5, y = -1) +
  stamp_spoke(angle = pi*0:3/6,
              color = "plum4",
                x = 5, y = -1) +
  stamp_ellipse(alpha = .5, 
                a = 2.2, b = 1,
                x0 = 3.2, y0 = .65, 
                angle = .12*pi) + 
  stamp_ellipse(x0 = 6:11/3, 
                y = -4:-9/4,
                a = .25, 
                b = .4, 
                alpha = .2,
                angle = pi*0:-5/5,
                fill = "slateblue",
                size = 0) +
  theme_void() +
  theme(panel.background = 
          element_rect(fill = "snow2", 
                       color = "snow2"))

r chunk_reveal("polygon")

ggcanvas() +
  stamp_polygon(color = "turquoise4", 
                radius = 3, n = 5, 
                fill = "turquoise") +
  stamp_polygon(fill = "slateblue2", 
                radius = 2, 
                n = 7) +
  stamp_polygon(linetype = "dashed", 
                alpha = .5, 
                x0 = 1:2,
                fill = "plum2") +
  stamp_polygon(x0 = 1, y0 = 1.5, 
                n = 3, rotation = .25, 
                size = 0,
                fill = "goldenrod2") +
  stamp_polygon(n = 50, 
                radius = .2, 
                size = 0) +
  stamp_spoke(angle = pi * 1:7/15, 
              radius = 2)

r chunk_reveal("spoke_positions")

ggcanvas() +
  stamp_label(label = "hello",
             x = spoke_x(n = 5),
             y = spoke_y(n = 5), size = 3) +
  stamp_point(x = spoke_x(n = 5, rot = 0),
              y = spoke_y(n = 5, rot = 0)) +
  stamp_label(label = c("hi", "bye", "chao"),
              size = 4,
              x = spoke_x(n = 3, rotation = -.5, radius = .5),
              y = spoke_y(n = 3, rotation = -.5, radius = .5)) + 
  stamp_polygon(x0 = wrap_x(x0 = 0, n = 5, ncol = 3),
                y0 = wrap_y(y0 = 3, n = 5, ncol = 3),
                radius = .4)

r chunk_reveal("png")

download.file(url = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
              destfile = "wiki.png")

ggcanvas() +
  stamp_png(x0y0 = wrap_png()) +
  stamp_png(x0y0 = wrap_png(y0 = -3, n = 8)) +
  stamp_png(x0y0 = wrap_png(y0 = -7.5, n = 3)) +
  stamp_png(x0 = 4, y0 = -1, width = 3) + 
  theme_void()

r chunk_reveal("backdrop")

#only supports pngs for now
magick::image_read("https://images.unsplash.com/photo-1593448806592-409752fd816b?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1500&q=80") %>% 
  magick::image_resize("300x") %>% 
  magick::image_write("stamp.png", 
                      format = "png") 

ggbackdrop(png = "stamp.png") +
  stamp_curve(curvature = .3, yend = .5) +
  stamp_polygon(x0 = .8, 
                y0 = .4, 
                radius = .2, 
                alpha = 0,
                color = "grey97") +
  stamp_text(x = .8, y = .4, 
             label = "{ggstamp}",
                color = "grey97") +
  theme_void()

r chunk_reveal("the_stamps", chunk_options = "fig.width = 8, fig.height = 6", break_type = "replace", replace = "point", replacements = c("point", "segment", "arrow", "curve", "spoke", "text", "label", "tile", "polygon"))

library(ggstamp)
ggcanvas() +
  stamp_point()

r chunk_reveal("the_stamps_functions", chunk_options = "fig.width = 8, fig.height = 6", break_type = "replace", replace = "point", replacements = c("point", "segment", "arrow", "curve", "spoke", "text", "label", "tile", "polygon"))

library(ggstamp)
stamp_point

r chunk_reveal("the_wraps", break_type = "replace", replace = "wrap", replacements = c("wrap", "spoke", "honeycomb"))

ggcanvas() +
  stamp_polygon(x0y0 = wrap(n = 7),
                radius = .4)

r chunk_reveal("the_wraps_functions", break_type = "replace", replace = "wrap", replacements = c("wrap", "spoke", "honeycomb"))

wrap_y

```{css, eval = TRUE, echo = FALSE} .remark-code{line-height: 1.5; font-size: 78%}

@media print { .has-continuation { display: block; } }

code.r.hljs.remark-code{ position: relative; overflow-x: hidden; }

code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } ```



EvaMaeRey/ggstamp documentation built on June 30, 2022, 11 p.m.