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?
Have a look at canvas globalCompositeOperation . The lighter composite type seems to fit what you're after.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.