When drawing an angle line (45 degrees) in a rectangle from a general point $p = (x,y)$ that located on the right or the top line of the rectangle. How can I find the intersection point $p2$ of this line with the rectangle?
In other words, I want to write the target point, $p2$, with my current information: $x, y, w, h$. (This variables are described in the picture below).
The point $(0,0)$ is in the top-right corner.