#' Check whether the color is light
#'
#' Functions to check whether a color's perceived brightness is light.
#'
#' @param x a any type color string or a javascript color object specifying.
#'
#' @return Return a boolean indicating whether the color's perceived brightness is light.
#' @export
#' @examples
#' is_light("#FFF")
#' is_light("#F1C")
#' is_light("not a color")
is_light <- function(x) {
cmd <- ifelse(is_js_object(x),
paste0("tinycolor(", x, ").isLight()"),
paste0("tinycolor(\"", x, "\").isLight()"))
out <- ifelse(v8_eval(cmd) == "TRUE", TRUE, FALSE)
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.