2d box intersect with line, find when a line intersects edge of a box

Hi all,

I have a scrolling world view bigger than my camera viewable rect, and an object outside the viewable area.

What i want to do is create a marker that sits on the edge of the viewable rect to point to where this object is in the world. The player is centered in the viewable rect. So i have a line between the center point and the target object outside the viewable rect. i need to find where this line intersects any of the 4 rectangles edges and return the x & y position of this point. Can anyone talk me through a way of working this out?

Thanks

2078242--135716--bound.jpg

Proper, mathematical way of doing this is probably trigonometry.
Less elegant way to just hack your way past this could be raycast.