9 Mar 2023

QGIS3: Neat trick to convert color name into color rgb string

color_mix_rgb('blue', 'white', 0)
Arguments to the function are color1: a color string, color2: a color string, ratio: the ratio at which the two colors will be mixed. The output is:
'0,0,255,255'
The usecase is converting a color name, stored in a field (field name is "color_name_code"), to a color string to be used for symbolizing layer features, like so:
color_mix_rgb("color_name_code", 'white', 0.2)
which will give me a bit of a pastel tone, by mixing white into the given "color_name_code" (blue, red, green, etc.) with a ratio of 0.2

No comments :

Post a Comment