Skip to content

Commit

Permalink
Here is the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhu233 committed Jan 23, 2024
1 parent 0397b23 commit 9779f52
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions R/spec_tools.R
Expand Up @@ -44,20 +44,14 @@ html_color_ <- function(color) {
!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 = ", "), ")"))
# }
# )
# 2024-01-23 Hao: Move it to a try catch flavor to catch some exception cases.
tryCatch({
rgba_code <- col2rgb(color, alpha = TRUE)
rgba_code[4] <- round(rgba_code[4])
return(paste0("rgba(", paste(rgba_code, collapse = ", "), ")"))
},
error = function(e) {return(as.character(color))}
)
}

html_color <- function(colors) {
Expand Down

0 comments on commit 9779f52

Please sign in to comment.