# Given a set of points with color values, finding a gradated color value from a given position

I guess the verb form of gradient is "gradate" and not "gradiate"?

Hi! I have a set of 2D points (actually 3D, but we can ignore the Y axis unless it's trivial) bound to color values. I'd like to know, given an arbitrary point in space, what the color would be if there was a smooth gradient between all of the defined points.

Here's a visual of what these points might look like.

In the above image, I would expect the color value to be an approximately equal mix between the Red, Cyan, Yellow and Purple points that surround the gizmo's location, since it lies approximately central to these four points.

This is a bit more complicated than I originally anticipated, because:

• Simply averaging all of the points and weighting by distance will not work. If I ask for the color at the red point's exact position, I want red's exact color - with zero influence from any other point.

• Likewise, if I'm inside the "quad" of 4 of the closest points, there should be no influence from points outside of that quad - as the surrounding points should "block" their influence.

I'm guessing this isn't a particularly unique problem, so if this algorithm has a name, feel free to let me know what it is and I'll chase it down! I'm having a surprising amount of difficulty Googling an example - possibly because I just don't have the right keywords.

Thanks!

• Difficult problem to define... for example your gizmo is in the red-teal-purple-yellow quad. It is also in the red-green-teal-yellow quad. Not to mention the red-teal-yellow-blue quad. Depending on your position, the closest points might not give you consistent results
– Jay
Commented Dec 14, 2021 at 1:09