From 55cfaea4230dd2f87874aeb32a1ee3a1e9819627 Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sat, 7 Sep 2024 00:19:28 +0900 Subject: [PATCH] Ink should be always greyed? (#210) * Ink should be always greyed? * Tweak * Break tests * Tweak --- R/gghighlight.R | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/R/gghighlight.R b/R/gghighlight.R index 4258d10..3c37028 100644 --- a/R/gghighlight.R +++ b/R/gghighlight.R @@ -435,17 +435,14 @@ bleach_layer <- function(layer, group_info, unhighlighted_params, unhighlighted_ default_unhighlighted_colour <- function(theme = list()) { - geom <- theme$geom - if (utils::packageVersion("ggplot2") <= "3.5.1" || is.null(geom)) { - return("#BEBEBEB2") - } + # ink is greyed, while paper doesn't + ink <- grDevices::col2rgb(scales::col2hcl(theme$geom$ink %||% "black", c = 0)) + paper <- grDevices::col2rgb(theme$geom$paper %||% "white") # cf. ggplot2:::col_mix - ink <- grDevices::col2rgb(geom$ink %||% "black") - paper <- grDevices::col2rgb(geom$paper %||% "white") # 0.745098 = col2rgb("grey") / col2rgb("white") - new <- (0.254902 * paper + 0.745098 * ink)[,1] - grDevices::rgb(new["red"], new["green"], new["blue"], alpha = 76, maxColorValue = 255) + new <- (0.254902 * ink + 0.745098 * paper)[,1] / 255 + grDevices::rgb(new["red"], new["green"], new["blue"], alpha = 0.698) } get_default_aes_param <- function(aes_param_name, geom, mapping, unhighlighted_colour) {