How to stretch camera to a rectangle?

Hello, given the World coordinates of the top left and bottom right of my game’s rectangle, how can I make it so an ortographic camera stretches to that rectangle? Note that I don’t want just height or just width to be on the edge. I want the camera to be stretched to the rectangle.

I started by trying to scale each object itself but i need to reposition according to viewport and scale each’s width which seems way more complicated.

I have attached examples of how it would look like, adapting to different resolutions.

You have to change or add the resolution in the game window. Then you might have to adjust the camera settings.