R/color_maps.R

Defines functions rgb_2_set_hsv rgb_2_rgba

rgb_2_rgba <- function(color, alpha)
{
  vals <- col2rgb(color,alpha=FALSE)

  result <- rgb(vals[1]/255, vals[2]/255, vals[3]/255, alpha)
  
  return(result)
}

rgb_2_set_hsv <- function(color, h=NULL, s=NULL, v=NULL)
{
 if (is.null(color))
 {
   color <- 'red'
 }
  
  vals <- col2rgb(color)
  vals <- rgb2hsv(vals[1],vals[2],vals[3])
  
  if (!is.null(h))
  {
    vals[1] = h
  }    
  if (!is.null(s))
  {
    vals[2] = s
  }
  if (!is.null(v))
  {
    vals[3] = v
  }
  result <- hsv(vals[1],vals[2],vals[3])

  return(result)
}

Try the hypervolume package in your browser

Any scripts or data that you put into this service are public.

hypervolume documentation built on Sept. 14, 2023, 5:08 p.m.