Imagine a couple radial gradients with some radius scattered in a plane. The centers of the gradients arranged like this, for example:
A D
B
C
E F
Now coming out of each of these centers is a radial gradient with some radius. I know how to create the gradients, but I am wondering how to combine these gradients when they overlap.
This above arrangement would look like the following image. As you can see, there is a red radial gradient at (0,0), blue at (3,0), yellow at (1,1), red at (2,2), etc, and they are all blended together. Additionally, there are varying radii containing each gradient.
Here is an example for what the blending of radial gradients in the following arrangement would look like:
B
A
I have tried to find reading about this, but there are surprisingly very few hits (only 5 or 6), all of which are how to do this in Illustrator or Photoshop. I have also tried to program my own, but the problem is that I do not know what to do when it comes to the intersection of gradients; averaging the colors is wrong and comes out choppy, and that is what my (rather long) first attempt did.
How could I achieve this effect where the gradients are blended together on iOS in Swift? Any suggestions, references, or anything is greatly appreciate