How to check if canvas objects overlap each other
        Posted  
        
            by 
                ?????? ???????
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by ?????? ???????
        
        
        
        Published on 2012-03-24T11:23:50Z
        Indexed on 
            2012/03/24
            11:29 UTC
        
        
        Read the original article
        Hit count: 245
        
I'm trying to check if two objects (e.g. a rectangle and a triangle) on a HTML5 canvas are overlapping each other.
Currently I can only check that by looking at the screen (having set globalCompositeOperation='lighter').
My first idea would have been to scan all over the canvas if the "lighter" (compare code snippet above) color exists in the canvas. But therefor I would have to look at every single pixel which was rather costly for what I need.
Is there a (better) alternative to automatically check if they are overlapping?
Best regards.
© Stack Overflow or respective owner