Follow-up to #657 and #646
To support specifications like lighten = 0.5 in addition to just lighten = TRUE we could use:
lighten_col = function(x, amount = 0.8) {
x = to_hcl(x)
hcl(
h = x[, "H"],
c = x[, "C"] * (1 - amount),
l = 100 - (100 - x[, "L"]) * (1 - amount),
alpha = attr(x, "alpha")
)
}
By default this yields similar colors as the current lighten_fill() which is based on seq_palette(..., n = 3)[3]. Because we just need the lightened color here (rather than a palette going from the full color to the lightened one), lighten_col() can be a little bit simpler and hence leads to slightly different output.
Additionally, we may want to build in a catch that makes sure that lighten_col("black") returns "lightgray" to be exactly consistent with base R.
Follow-up to #657 and #646
To support specifications like
lighten = 0.5in addition to justlighten = TRUEwe could use:By default this yields similar colors as the current
lighten_fill()which is based onseq_palette(..., n = 3)[3]. Because we just need the lightened color here (rather than a palette going from the full color to the lightened one),lighten_col()can be a little bit simpler and hence leads to slightly different output.Additionally, we may want to build in a catch that makes sure that
lighten_col("black")returns"lightgray"to be exactly consistent with base R.