knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dplyr)
library(purrr)
library(sf)
library(packcircles)
library(ggplot2)
library(ishihara)
library(ishihara)

Here's the goal:

  1. Create a bunch of circles with packcircles.
  2. Convert those circles to an SF object.
  3. Pull in a vector font.
  4. Convert that font into an SF object
  5. Overlay the two SF objects and see where they intersect
  6. Plot the circles that are intersected by the text
  7. Change the colour palette in ggplot2 to see the impact of colourblindness

1. Create a bunch of circles

circle_plate <- create_circle_plate()

2. Convert circles to an sf spatial object.

circle_plate_sf <- cast_packing_poly(circle_plate)

3. Pull in a vector font (and resize the font)

letter_s <- glyph("s") %>% font_rescale(circle_plate)

4. Convert that font into an SF object

letter_s_sf <- cast_font_sf(letter_s)

5. Overlay the two SF objects and see where they intersect

overlayed_circle <- overlay_text_in_circle(circle_plate_sf, letter_s_sf)

6. plot the object

gg_ishihara <- ggplot(overlayed_circle) +
  geom_sf(aes(fill = in_text),
          colour = "white") +
  theme_void() +
  theme(legend.position = "none")

7. Change the colour palette in ggplot2 to see the impact of colourblindness

gg_ishihara + scale_fill_viridis_d()


njtierney/ishihara documentation built on May 31, 2020, 9:01 a.m.