You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 satır
573B

  1. library(tidyverse)
  2. read_colors <- function(file) {
  3. text <- readLines(file, warn = FALSE) %>%
  4. str_subset("#[0-9a-fA-F]{6}") # must be len-6 hex
  5. str_match_all(text, "\\$(.+)\\s*:\\s*(#[0-9a-fA-F]{6});") %>%
  6. discard(~ length(.) < 1) %>%
  7. map_dfr(~ tibble(name = .[, 2], color = .[, 3])) %>%
  8. distinct(name, color) %>%
  9. mutate(name = factor(name, unique(name)))
  10. }
  11. show_colors <- function(colors) {
  12. ggplot(colors) +
  13. aes(1, 1, fill = color) +
  14. geom_tile() +
  15. facet_wrap(~ name + color) +
  16. scale_fill_identity() +
  17. theme_void()
  18. }