I am looking to create a water fill effect into a shape and am using WaveViewAnimation project.
I want to allow the user to press on different buttons to create different colour waves to fill the shape. And when user presses on second colour while the first colour is
waveRed = WaveAnimationView(frame: CGRect(origin: .zero, size: lapView.bounds.size), color: UIColor.red.withAlphaComponent(0.5))
lapView.addSubview(waveRed)
waveBlue = WaveAnimationView(frame: CGRect(origin: .zero, size: lapView.bounds.size), color: UIColor.green.withAlphaComponent(0.5))
lapView.addSubview(waveBlue)
waveRed.layer.zPosition = 1
waveBlue.layer.zPosition = 1
waveRed.startAnimation()
waveBlue.startAnimation()
I want the output something like the combination of 2 colours blended, something like the If red wave is filled and green was is pressed. The wave overlap area needs to be in yellow colour.
Could someone please guide me/advice me how to achieve this.

You may be able to get your desired result by using the
.compositingFilterproperty ofCALayer.There are various "blend" filters... this one:
is probably what you want to play with.
Apple's docs on it are vague -
Of course, the link doesn't help... but I did find this from searching:
So, if we have a red circle overlapping a green circle...
We get this with NO filter (or the default "normalBlendMode"):
If we give the red circle layer
.compositingFilter = "screenBlendMode"we get this:As we see, "screen blending"
1, 0, 0, 1(red) with0, 1, 0, 1(green) gives us1, 1, 0, 1-- yellow.Notice that we lose the "top" of the red circle. That's because any color screen-blended with white results in white.
If we add another "bottom" layer matching the top red layer, like this:
We'll get this result:
because, as we'd expect, any color screen-blended with itself results in itself.
Here's the sample code I used to produce these images that you can play with:
Each tap anywhere on the screen will step through the different blend-modes and "bottom layer" visibility.