Skip to content

Commit 8564981

Browse files
committed
remove shims
1 parent 60f85b1 commit 8564981

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

R/utilities.R

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -852,56 +852,6 @@ warn_dots_used <- function(env = caller_env(), call = caller_env()) {
852852
)
853853
}
854854

855-
# TODO: delete shims when {scales} releases >1.3.0.9000
856-
# and bump {scales} version requirements
857-
# Shim for scales/#424
858-
col_mix <- function(a, b, amount = 0.5) {
859-
input <- vec_recycle_common(a = a, b = b, amount = amount)
860-
a <- grDevices::col2rgb(input$a, TRUE)
861-
b <- grDevices::col2rgb(input$b, TRUE)
862-
new <- (a * (1 - input$amount) + b * input$amount)
863-
grDevices::rgb(
864-
new["red", ], new["green", ], new["blue", ],
865-
alpha = new["alpha", ], maxColorValue = 255
866-
)
867-
}
868-
869-
# Shim for scales/#427
870-
as_discrete_pal <- function(x, ...) {
871-
if (is.function(x)) {
872-
return(x)
873-
}
874-
pal_manual(x)
875-
}
876-
877-
# Shim for scales/#427
878-
as_continuous_pal <- function(x, ...) {
879-
if (is.function(x)) {
880-
return(x)
881-
}
882-
is_color <- grepl("^#(([[:xdigit:]]{2}){3,4}|([[:xdigit:]]){3,4})$", x) |
883-
x %in% grDevices::colours()
884-
if (all(is_color)) {
885-
colour_ramp(x)
886-
} else {
887-
stats::approxfun(seq(0, 1, length.out = length(x)), x)
888-
}
889-
}
890-
891-
# Replace shims by actual scales function when available
892-
on_load({
893-
nse <- getNamespaceExports("scales")
894-
if ("col_mix" %in% nse) {
895-
col_mix <- scales::col_mix
896-
}
897-
if ("as_discrete_pal" %in% nse) {
898-
as_discrete_pal <- scales::as_discrete_pal
899-
}
900-
if ("as_continuous_pal" %in% nse) {
901-
as_continuous_pal <- scales::as_continuous_pal
902-
}
903-
})
904-
905855
# TODO: Replace me if rlang/#1730 gets implemented
906856
# Similar to `rlang::check_installed()` but returns boolean and misses
907857
# features such as versions, comparisons and using {pak}.

0 commit comments

Comments
 (0)