# Distance to rect edge from point based on direction

I have a rect that is at position (0,0) at the top left and is 2200x2200 in size.

I am trying to specify the the distance to get to the edge of the rect in specific direction (degrees) from a point within the rect.

So say I am at point 50,50, and want to move 270 degrees until I hit the coordinate of the edge of the rect. What would be the best way to go about this?

Right now I have another function I use to get distance based on direction

distance = 2200
direction = 315