Resizing video keeping the WxH relationship without math by hand

Hello all.

I’m looking to keep a certain video on the center of the screen without stretching. What is the fastest way to keep every loaded video in the center of some rectangle? I have .draw(x, y, w, h) and it in fact is “hardcoded” to be always in the center. But the video texture may not match these coordinates and will end up stretching. Is it possible to resize the video keeping the aspect ratio without doing the math by hand?

Thanks in advance.

video.draw(rect.width * 0.5 - video.getWidth() * 0.5, rect.height * 0.5 - video.getHeight() * 0.5);

I like using ofRectangle.

ofRectangle screen(0,0,ofGetWidth(), ofGetHeight());
ofRectangle vidRect(0,0, video.getWidth(), video.getHeight());
vidRect.scaleTo(screen, OF_SCALEMODE_CENTER);

Even when it is a bit longer than @dimitre 's answer using rectangles allows to to align these very easily. Take a look at ofRectangle’s methods, as there are a lot that are really useful. (Hint: ofRectangle.h has a very thorough inline documentation for each function. just open it and read).