improve color code setting
diff --git a/R/spec_tools.R b/R/spec_tools.R
index 7708118..03b2539 100644
--- a/R/spec_tools.R
+++ b/R/spec_tools.R
@@ -6,13 +6,37 @@
 #' @export
 spec_color <- function(x, alpha = 1, begin = 0, end = 1,
                        direction = 1, option = "D",
-                       na_color = "#BBBBBBFF") {
+                       na_color = "#BBBBBB") {
   x <- round(rescale(x, c(1, 256)))
   color_code <- viridisLite::viridis(256, alpha, begin, end, direction, option)[x]
   color_code[is.na(color_code)] <- na_color
   return(color_code)
 }
 
+html_color_ <- function(color) {
+  if (substr(color, 1, 1) != "#" | nchar(color) != 9) return(color)
+  rgba_code <- col2rgb(color, alpha = TRUE)
+  rgba_code[4] <- round(rgba_code[4] / 255, 2)
+  return(paste0("rgba(", paste(rgba_code, collapse = ", "), ")"))
+}
+
+html_color <- function(colors) {
+  sapply(colors, html_color_)
+}
+
+latex_color_ <- function(color) {
+  if (substr(color, 1, 1) != "#") {
+    return(paste0("{", color, "}"))
+  } else {
+    color <- sub("#", "", color)
+    if (nchar(color) == 8) color <- substr(color, 1, 6)
+    return(paste0("[HTML]{", color, "}"))
+  }
+}
+latex_color <- function(colors) {
+  sapply(colors, latex_color_)
+}
+
 #' Generate common font size for continuous values
 #'
 #' @param x continuous vectors of values