Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Does Scratch automatically round X position, Y position, and Size values?
- NMario84
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
If I try to set a sprite size to something like 123.5, the sprite info data says it is size 124. It seems to round that value UP if it is 0.5 or more. But if it is 0.4 or less (for example, 123.4), it stays at the value 123.
The reason I set a sprite size with a decimal, for example, 187.5 is because of the original game screen I'm using as the base is 256x192. Scratch's screen is 480x360. So if you multiply 256 by 1.875 (or 187.5 in %), it gives 480. Same for the other value, multiply 192 by 1.875, it gives 360.
So I guess you can't avoid any of the automatic rounding for this case?
The reason I set a sprite size with a decimal, for example, 187.5 is because of the original game screen I'm using as the base is 256x192. Scratch's screen is 480x360. So if you multiply 256 by 1.875 (or 187.5 in %), it gives 480. Same for the other value, multiply 192 by 1.875, it gives 360.
So I guess you can't avoid any of the automatic rounding for this case?
- scratchcode1_2_3
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
I mean, for x and y positions I don't think it rounds them, but it does for size.
edit: it might be because I've never had a situation where I've needed to set size to a decimal, so i guess not many other people use it either
edit: it might be because I've never had a situation where I've needed to set size to a decimal, so i guess not many other people use it either
Last edited by scratchcode1_2_3 (Aug. 28, 2023 22:02:48)
- Zydrolic
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
yeah, it does:
(keep the number “1” in mind)

in the project's json file, i actually set it to really specific number (0.5222)

edit: yes, the sb3 the file is from indeed did get rounded.
you can look through the json yourself, i cannot share it however.
replicating it isnt that difficult so it's doable.
(keep the number “1” in mind)

in the project's json file, i actually set it to really specific number (0.5222)

edit: yes, the sb3 the file is from indeed did get rounded.
you can look through the json yourself, i cannot share it however.
replicating it isnt that difficult so it's doable.
Last edited by Zydrolic (Aug. 28, 2023 22:06:58)
- CST1229
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
From my testing:
- The actual x/y/size values (in the .sb3) are not rounded
- Most displayed x/y/size values (e,g in sprite properties and in variable monitors) are rounded
- Reported (from the reporter blocks) x/y values are not rounded, but sizes are
- Rendered x/y positions are rounded to stage pixels
- Rendered sizes are not rounded (fractional sizes are visible)
- NMario84
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
Yea this is interesting indeed. the sprite data of X, Y, and size shown below the stage window are rounded.
When you see the actual reporter blocks, they are exactly what you use.
Though the reporter block for the size seems to round anyway, even when I set it to 123.45. Though I don't find any reason that the size should do this if the X and Y doesn't change for the reporters.
The direction reporter shows the decimal point value, even though the value seems to round in the data below the stage with the other values.
When you see the actual reporter blocks, they are exactly what you use.
Though the reporter block for the size seems to round anyway, even when I set it to 123.45. Though I don't find any reason that the size should do this if the X and Y doesn't change for the reporters.
The direction reporter shows the decimal point value, even though the value seems to round in the data below the stage with the other values.
- D-ScratchNinja
-
Scratcher
1000+ posts
Does Scratch automatically round X position, Y position, and Size values?
When sprites are displayed on the stage, their X and Y positions appear rounded off, but not their direction or size.
The size reporter is the only one that rounds off, so your code can't actually tell exactly how big your sprites are. However, getting the size of a sprite with this block:
All values are rounded on the sprite properties area, but that's also just visual.
And all values are stored in the project file exactly, from what I believe.
The size reporter is the only one that rounds off, so your code can't actually tell exactly how big your sprites are. However, getting the size of a sprite with this block:
([size v] of [Sprite1 v])…does not return a rounded value.
All values are rounded on the sprite properties area, but that's also just visual.
And all values are stored in the project file exactly, from what I believe.
- Discussion Forums
- » Questions about Scratch
-
» Does Scratch automatically round X position, Y position, and Size values?




