Skip to contents

Modify a color parameter as saturation, light or alpha parameter.

Usage

MutateColorParameter(
  color.col = NULL,
  operation.str = NULL,
  parameter.str = NULL,
  alpha.bln = FALSE,
  prctMutation.num = 0.2
)

Arguments

color.col

<character or numeric>: color in any format.

operation.str

<character>: must be one of "=", "+", "-", "*", "/", "%*%" or "%/%".

  • "=" put the choosen parameter at the prctMutation value; e.g if parameter=0.6 and prctMutation.num=0.2 returned parameter=0.2

  • "+" add at the choosen parameter the prctMutation value; e.g if parameter = 0.6 prctMutation.num=0.2 returned parameter=0.8 (0.6+0.2)

  • "-" subtract at the choosen parameter the prctMutation value; e.g if parameter = 0.6 and prctMutation.num = 0.2 returned parameter=0.4 (0.6-0.2)

  • "*" increases the choosen parameter of the prctMutation value; e.g if parameter = 0.6 and prctMutation.num = 0.2 returned parameter=0.72 (0.6 + 0.6*0.2)

  • "/" decreases the choosen parameter of the prctMutation value; e.g if parameter = 0.6 and prctMutation.num = 0.2 returned parameter=0.48 (0.6 - 0.6*0.2)

  • "%*%" increases the choosen parameter of the prctMutation value of the rest; e.g if parameter = 0.4 and prctMutation.num = 0.2 returned parameter=0.68 (0.6 + 0.4*0.2)

  • "%/%" decreases the choosen parameter of the prctMutation value of the rest; e.g if parameter = 0.4 and prctMutation.num = 0.2 returned parameter=0.32 (0.6 - 0.4*0.2)

parameter.str

<character>: the parameter that will be modify (one of "saturation", "light", "alpha").

alpha.bln

<logical>: whether the alpha layer should be returned. (Default FALSE)

prctMutation.num

<numeric>: the percentage of modification. Must be between [0-1]. (Default 0.2)

Value

The mutated color.

Details

MutateColorParameter

Examples

MutateColorParameter(
    color.col="#ebb0107f",
    operation.str="+",
    parameter.str="light",
    alpha.bln=TRUE,
    prctMutation.num=0.2
)
#> [1] "#f5d06c7f"