Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if two rectangles overlap javascript canvas

// Where left, right, top and bottom are essentially edges

if (a.left >= b.right || a.top >= b.bottom || 
    a.right <= b.left || a.bottom <= b.top)
{
    // no overlap
}
else
{
    // overlap
}
 
PREVIOUS NEXT
Tagged: #check #rectangles #overlap #javascript #canvas
ADD COMMENT
Topic
Name
3+5 =