Reputation: 303
I have two blocks in HTML5 canvas.
When someone moves the yellow block over blue block, I want to change the color of overlapping or intersection regions to green. (please see attached image to have clear idea)
Since blue + yellow = green, is there any way to achieve this by changing the opacity level of blocks or I have to search for the overlapping area of the two blocks and display green block in that area or is there any other way?
I would like to know what is the best approach to achieve this?
Upvotes: 4
Views: 379
Reputation: 5713
You could use 3 elements:
This is far from done, but maybe a step in the right direction.
EDIT: I noticed too late that you requested it on canvas, but the principe should be the same there.
Upvotes: 0
Reputation: 5268
Have a look at canvas globalCompositeOperation. The lighter composite type seems to fit what you're after.
Upvotes: 2