Motivation: Post-process a finite element solver answer file (in my case FEMM).
I'm creating a mesh with Python with the following code (well, my actual code is a bit more complex, but it doesn't matter).
import bpy
mesh = bpy.data.meshes.new("NewMesh") # add the new mesh
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get("Collection")
col.objects.link(obj)
bpy.context.view_layer.objects.active = obj
verts = [(0, 0, 0),
(1, 1, 0),
(1, -1, 0),
(-1, -1, 0),
(-1, 1, 0),
]
edges = []
faces = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1]]
face_values = [-1.5, 10, -5, 3]
mesh.from_pydata(verts, edges, faces)
With Python (I have 10000+ faces to colorize), how can I affect a separate color to each face depending on the corresponding value in face_values (based on a color map)?
I'd like to achieve something like that (except that all faces should have a uniform color).
Here is an example that I faked using texture painting:
with [-1.5, 10, -5, 3] corresponding to [red, blue, green, white].


