R/colorMult.R

Defines functions col.mult

Documented in col.mult

col.mult <- function(col1 = 0x000000, col2 = "gray50"){
  #' col.mult
  #' @export 

  int2rgb <- function(x){
    # by Mickey Warner
    hex <- as.character(as.hexmode(x))
    hex <- paste0("#", paste0(rep("0", 6-nchar(hex)), collapse=""), hex)
    col2rgb(hex)
  }

  if (is.character(col1))
      val1 <- t(col2rgb(col1) / 255)
  if (is.numeric(col1))
      val1 <- t(int2rgb(col1) / 255)
  if (is.character(col2))
      val2 <- t(col2rgb(col2) / 255)
  if (is.numeric(col2))
      val2 <- t(int2rgb(col2) / 255)

  rgb(val1 * val2)
}
luiarthur/rcommon documentation built on Jan. 18, 2021, 12:45 a.m.