I have been searching here and on the net. I found somehow close questions/answers to what I want, but still couldn\'t reach to what I\'m looking for.
I have an arra
It depends on what units you need your colours to be in, but just a simple if statement should do the trick.
def find_colour(_val):
# Colour value constants
_colours = {"blue": [0.0, 0.0, 1.0],
"green": [0.0, 1.0, 0.00],
"yellow": [1.0, 1.0, 0.0],
"red": [1.0, 0.0, 0.0]}
# Map the value to a colour
_colour = [0, 0, 0]
if _val > 30:
_colour = _colours["red"]
elif _val > 20:
_colour = _colours["blue"]
elif _val > 10:
_colour = _colours["green"]
elif _val > 0:
_colour = _colours["yellow"]
return tuple(_colour)
And just convert that tuple to whatever units you need e.g. RGBA(..). You can then implement the methods it looks like you have already found to achieve the grid.