Skip to content

Commit

Permalink
Ink should be always greyed? (#210)
Browse files Browse the repository at this point in the history
* Ink should be always greyed?

* Tweak

* Break tests

* Tweak
  • Loading branch information
yutannihilation authored Sep 6, 2024
1 parent f3754b9 commit 55cfaea
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions R/gghighlight.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 55cfaea

Please sign in to comment.