Skip to content

Commit

Permalink
reverse the change
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhu233 committed Jan 23, 2024
1 parent 8b76cca commit 0397b23
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions R/spec_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,24 @@ spec_color <- function(x, alpha = 1, begin = 0, end = 1,
html_color_ <- function(color) {
# HTML colors are a subset of R colors, not including
# numbered versions like darkgoldenrod2 (issue #726)
# 2024-01-23 Hao: Move it to a try catch flavor.
tryCatch(
{rgba_code <- col2rgb(color, alpha = TRUE)},
error = function(e) {return(color)},
warning = function(w) {return(color)},
finally = function(f) {
rgba_code[4] <- round(rgba_code[4])
return(paste0("rgba(", paste(rgba_code, collapse = ", "), ")"))
}
)
if (substr(color, 1, 1) != "#" &&
!grepl("[[:digit:]]", color) )
return(color)

rgba_code <- col2rgb(color, alpha = TRUE)
rgba_code[4] <- round(rgba_code[4])
return(paste0("rgba(", paste(rgba_code, collapse = ", "), ")"))

# # 2024-01-23 Hao: Move it to a try catch flavor.
# tryCatch(
# {rgba_code <- col2rgb(color, alpha = TRUE)},
# error = function(e) {return(color)},
# warning = function(w) {return(color)},
# finally = function(f) {
# rgba_code[4] <- round(rgba_code[4])
# return(paste0("rgba(", paste(rgba_code, collapse = ", "), ")"))
# }
# )
}

html_color <- function(colors) {
Expand Down

0 comments on commit 0397b23

Please sign in to comment.