line-rect-hit demo
Drag a line end or box corner to move a line or box.
Is the yellow line hitting the box?
Is the yellow line hitting the red line?