| library(ggplot2) | library(ggplot2) | ||||
| source("R/make_functions.R") | source("R/make_functions.R") | ||||
| source("R/show_colors.R") | source("R/show_colors.R") | ||||
| fs::dir_create("docs/palettes") | |||||
| themes <- list( | themes <- list( | ||||
| "Solarized" = "_solarized.scss", | "Solarized" = "_solarized.scss", | ||||
| "One Dark" = "_one-dark.scss" | "One Dark" = "_one-dark.scss" | ||||
| ) | ) | ||||
| pal_files <- c() | |||||
| for (theme in names(themes)) { | for (theme in names(themes)) { | ||||
| theme_file <- fs::path("src", "palettes", themes[[theme]]) | theme_file <- fs::path("src", "palettes", themes[[theme]]) | ||||
| colors <- read_colors(theme_file) | colors <- read_colors(theme_file) | ||||
| theme( | theme( | ||||
| plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)) | plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)) | ||||
| ) | ) | ||||
| print(g) | |||||
| knitr::opts_current$set(fig.process = function(x) { | |||||
| x2 <- sub("([.][a-z]+$)", paste0(themes[[theme]], "\\1"), x) | |||||
| if (file.rename(x, x2)) x2 else x1 | |||||
| }) | |||||
| pal_file <- fs::path("docs", "palettes", themes[[theme]]) | |||||
| fs::path_ext(pal_file) <- "png" | |||||
| ggsave(pal_file, g, width = 10, height = 4) | |||||
| pal_files <- c(pal_files, pal_file) | |||||
| } | } | ||||
| knitr::include_graphics(pal_files) | |||||
| ``` | ``` | ||||
| ### Base 16 Palettes | ### Base 16 Palettes | ||||
| ```{r base16, fig.width=10, fig.height=4} | ```{r base16, fig.width=10, fig.height=4} | ||||
| base16_palettes <- fs::dir_ls(here::here("src", "palettes", "base16"), regexp = "_base16") | base16_palettes <- fs::dir_ls(here::here("src", "palettes", "base16"), regexp = "_base16") | ||||
| pal_files <- c() | |||||
| for (base16_pal in base16_palettes) { | for (base16_pal in base16_palettes) { | ||||
| base16_info <- get_base16_theme_info(base16_pal) | |||||
| base16_info <- base16_get_theme_info(base16_pal) | |||||
| attribution <- stringr::str_remove_all(base16_info$attribution, "(\\s*?(/?\\*/?)\\s*?)") | attribution <- stringr::str_remove_all(base16_info$attribution, "(\\s*?(/?\\*/?)\\s*?)") | ||||
| attribution <- stringr::str_split(attribution, "by")[[1]] | attribution <- stringr::str_split(attribution, "by")[[1]] | ||||
| attribution <- stringr::str_trim(attribution) | attribution <- stringr::str_trim(attribution) | ||||
| plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)), | plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)), | ||||
| plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 10)) | plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 10)) | ||||
| ) | ) | ||||
| print(g) | |||||
| pal_file <- fs::path("docs", "palettes", fs::path_file(base16_pal)) | |||||
| fs::path_ext(pal_file) <- "png" | |||||
| ggsave(pal_file, g, width = 10, height = 4) | |||||
| pal_files <- c(pal_files, pal_file) | |||||
| } | } | ||||
| knitr::include_graphics(pal_files) | |||||
| ``` | ``` |
| <!-- badges: end --> | <!-- badges: end --> | ||||
| `rstudio-scss` provides SCSS/SASS templates for full RStudio themes for | `rstudio-scss` provides SCSS/SASS templates for full RStudio themes for | ||||
| RStudio version 1.2 (and possibly RStudio 1.2+). | |||||
| RStudio version 1.2 (and possibly RStudio | |||||
| 1.2+). | |||||
| ## Palettes | ## Palettes | ||||
| <!-- --><!-- --><!-- --><!-- --><!-- --> | |||||
| <!-- --><!-- --><!-- --><!-- --><!-- --> | |||||
| ### Base 16 Palettes | ### Base 16 Palettes | ||||
| <!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --> | |||||
| <!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --> |