SFML community forums

General => Feature requests => Topic started by: panithadrum on January 21, 2010, 09:56:11 pm

Title: sf::Sprite::GetWidth&GetHeight
Post by: panithadrum on January 21, 2010, 09:56:11 pm
If you have a sprite that have assigned an image with (x, y) size, would be nice to have a function that returns the image size per sprite's scale.

Example:
Code: [Select]
Image img
Load img
Sprite spr
Assign img to spr
Scale spr 1/2, 1/2
-> Get spr width
-> Get spr height
Title: sf::Sprite::GetWidth&GetHeight
Post by: Nexus on January 21, 2010, 10:15:31 pm
Something like this?
Code: [Select]
sf::Vector2f GetScaledImageSize(const sf::Sprite& sprite)
{
return sf::Vector2f(
sprite.GetScale().x * sprite.GetImage()->GetWidth(),
sprite.GetScale().y * sprite.GetImage()->GetHeight());
}

I don't think this is so often required that an integration into SFML were really justified...
Title: sf::Sprite::GetWidth&GetHeight
Post by: panithadrum on January 21, 2010, 10:29:15 pm
Yeah, something like that :o
Title: sf::Sprite::GetWidth&GetHeight
Post by: Laurent on January 21, 2010, 10:30:37 pm
Yeah, that sounds a little weird. I can understand that you need the image size, or the sprite's size, but why the "image size scaled by the sprite's factor"??

If you need to get the sprite's size (which is the scaled subrect, not the entire image scaled), then you have sf::Sprite::GetSize.