Created
March 14, 2023 20:43
-
-
Save AlbertRapp/3e3098971e20d51df1fac140b158010f to your computer and use it in GitHub Desktop.
icon_dice.qmd
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
```{r} | |
library(tidyverse) | |
library(showtext) | |
library(ggtext) | |
font_add('fa-solid', '00_fonts/Font Awesome 6 Free-Solid-900.otf') | |
showtext_auto() | |
showtext_opts(dpi = 300) | |
camcorder::gg_record( | |
dir = 'img', | |
device = 'png', | |
width = 16, | |
height = 16, | |
units = 'cm' | |
) | |
``` | |
```{r} | |
set.seed(345345) | |
unicode_dice <- c('f554', 'f5c4', 'f7ce', 'f7c5', 'f6ec', 'f84a') | |
dice_simulation <- expand_grid( | |
col = 1:16, | |
row = 1:14 | |
) |> | |
mutate( | |
unicode = sample(unicode_dice, size = length(row), replace = TRUE), | |
label = glue::glue("<span style='font-family:fa-solid'>&#x{unicode};</span>"), | |
color = case_when( | |
between(col, 1, 4) ~ '#a70f2d', | |
between(col, 5, 8) ~ '#00726e', | |
between(col, 9, 12) ~ '#cf501c', | |
between(col, 13, 16) ~ '#0a2c96' | |
) | |
) | |
``` | |
```{r} | |
dice_simulation |> | |
ggplot(aes(x = col, y = row, label = label, color = color)) + | |
geom_richtext(size = 7, label.colour = NA, fill = NA) + | |
theme_void() + | |
theme(plot.background = element_rect(fill = 'white', colour = NA)) + | |
scale_color_identity() | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment