Function: recolor_image

Function: recolor_image

since 0.3.9

Usage

 recolor_image(input: image, color: color)
 recolor_image(input: image, red: color, green: color, blue: color, white: color)

Re-color an image:

  • Red is replaced by the color
  • Green is replaced by black or white, of the same lightness as the color. So if the color is light, green will be replaced by white.
  • Blue is replaced by black or white, of the opposite lightness.
  • White stays white, black stays black

This function is mostly intended to make symbols in a symbol font wich can match the text color.

Parameters

Parameter Type Description
input image Image to recolor.
color color Color by which to replace red.

Or

Parameter Type Description
input image Image to recolor.
red color Color by which to replace red.
green color Color by which to replace green.
blue color Color by which to replace blue.
white color Color by which to replace white.

Examples

 recolor_image("symbol1.png", color: rgb(180,0,0)) == [[Image]]
 recolor_image("symbol1.png", color: rgb(180,0,0)) == "symbol1_red.png"
 recolor_image("symbol1.png", color: rgb(100,255,0)) == [[Image]]
 recolor_image("symbol1.png", color: rgb(100,255,0)) == "symbol1_green.png"

Custom choices for green, blue and white are also possible:

 recolor_image("symbol1.png", red:rgb(0,170,0), green:rgb(200,0,255), blue:rgb(128,0,0), white:rgb(220,255,0))
    ==  "symbol1_recolor_custom.png"