SFML community forums

Help => Graphics => Topic started by: Austech on February 01, 2010, 09:52:19 am

Title: Scale a Sprite to fit a whole window?
Post by: Austech on February 01, 2010, 09:52:19 am
Is there a mathematical way to scale a sprite to fit a whole window? I tried scaling it like:

Scale(WindowWidth - ImageWidth,WindowHeight - ImageHeight);

But It seems to scale way too big. So is there a way to do it?

Once again thanks in advanced.
Title: Scale a Sprite to fit a whole window?
Post by: Laurent on February 01, 2010, 10:06:23 am
The scale is a factor that it multiplied to the original size, not added. So you should call
Code: [Select]
sprite.Scale(WindowWidth / ImageWidth, WindowHeight / ImageHeight);
Or simply use Resize, which does this job for you
Code: [Select]
sprite.Resize(WindowWidth, WindowHeight);
Title: Scale a Sprite to fit a whole window?
Post by: Austech on February 01, 2010, 10:34:05 am
Thanks, the resize function worked perfectly.  :)