Created
April 5, 2021 02:15
-
-
Save yjunechoe/b62bf14257f6f9c4bcde67299f830347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(dplyr) | |
| library(ggplot2) | |
| library(gganimate) | |
| library(string2path) | |
| magic <- string2path( | |
| "MAGIC", | |
| paste0(Sys.getenv("FONT_PATH"), "xkcd.ttf") | |
| ) | |
| magic_points <- magic %>% | |
| group_by(glyph_id) %>% | |
| mutate(across(c(x, y), ~ min(.x) + (max(.x) - min(.x))/2, .names = "{.col}1")) %>% | |
| rename(x2 = x, y2 = y) %>% | |
| # "letter spacing" | |
| mutate(across(starts_with("x"), ~ .x + seq(-5, 5, length.out = 5)[cur_group_id()])) %>% | |
| ungroup() | |
| magic_points %>% | |
| tidyr::pivot_longer( | |
| matches("^[xy]"), | |
| names_to = c(".value", "state"), | |
| names_pattern = "(.)(.)" | |
| ) %>% | |
| ggplot(aes(x, y, group = glyph_id, fill = factor(glyph_id))) + | |
| geom_polygon(show.legend = FALSE) + | |
| scale_fill_manual(values = colorspace::rainbow_hcl(6, c = 80)) + | |
| theme_void() + | |
| transition_states(state) + | |
| ease_aes("bounce-in-out") |
Author
yjunechoe
commented
Apr 5, 2021

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment