Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Scaling Sprite to integer sizes
Print
Pages: [
1
]
Author
Topic: Scaling Sprite to integer sizes (Read 2870 times)
0 Members and 1 Guest are viewing this topic.
barnack
Jr. Member
Posts: 56
Scaling Sprite to integer sizes
«
on:
May 13, 2019, 06:42:15 pm »
Hi,
is there any way to force the size of a sprite to be rounded after scaling? I didn't find anything except a "setSize" that existed in previous SFML versions...
Logged
Elias Daler
Hero Member
Posts: 599
Re: Scaling Sprite to integer sizes
«
Reply #1 on:
May 13, 2019, 07:24:21 pm »
It's very strange that this function doesn't exist indeed.
The workaround is to use sf::RectangleShape, I guess.
I wonder why it was removed.
Logged
Tomb Painter, Re:creation dev (abandoned, doing other things) |
edw.is
|
@EliasDaler
Laurent
Administrator
Hero Member
Posts: 32498
Re: Scaling Sprite to integer sizes
«
Reply #2 on:
May 13, 2019, 08:07:03 pm »
Because setSize is really just setScale(size / textureRect.size).
Logged
Laurent Gomila - SFML developer
Elias Daler
Hero Member
Posts: 599
Re: Scaling Sprite to integer sizes
«
Reply #3 on:
May 13, 2019, 09:38:10 pm »
Yeah, but you can get a ton of rounding errors because of division/multiplication.
Logged
Tomb Painter, Re:creation dev (abandoned, doing other things) |
edw.is
|
@EliasDaler
Laurent
Administrator
Hero Member
Posts: 32498
Re: Scaling Sprite to integer sizes
«
Reply #4 on:
May 13, 2019, 10:14:11 pm »
If so, setSize did not solve anything
Logged
Laurent Gomila - SFML developer
Elias Daler
Hero Member
Posts: 599
Re: Scaling Sprite to integer sizes
«
Reply #5 on:
May 13, 2019, 10:21:17 pm »
Ah, I remembered how Transformable stores scale and later computes transform matrix.
Yeah, in this case getting rounding errors is inevitable.
OP should probably use RectangleShape for precise integer sprite sizes, yeah.
Logged
Tomb Painter, Re:creation dev (abandoned, doing other things) |
edw.is
|
@EliasDaler
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Scaling Sprite to integer sizes