Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » How does zoom actually work?
- kelolli
- New to Scratch
3 posts
How does zoom actually work?
For a sprite that is, say, 100x100 in size, how big will it be at zoom 50%? 25%?
It's not a literal percentage of the size, is it? (Or the sprite would go to 1 pixel at 1%?)
thx
It's not a literal percentage of the size, is it? (Or the sprite would go to 1 pixel at 1%?)
thx
- kelolli
- New to Scratch
3 posts
How does zoom actually work?
For more context on what I'm actually trying to do — I'm looking to zoom in and out on the screen. So there is a bit of math that I need to do. If the user has “zoomed out” than the sprite should actually get smaller (say 50%) and then move closer to the center of the screen. But just moving it halfway between it's current x/y and 0/0 doesn't seem to look exactly right, so I was wondering if anyone knew the math on how the size of the sprite was actually changing.
thx
thx
- turkey3
- Scratcher
1000+ posts
How does zoom actually work?
Good question! Say your size is 100x100. 100% zoom is 100x100 pixels. But if it's 50%, take 50% of 100. That would make the sprite 50x50 pixels. 45% is 45x45 pixels. But, say the sprite is a 50x25 pixel sprite. In this case, the width is 50 and the height is 25. No matter what the zoom is, those two dimensions stay proportional and keep their aspect ratio. So, in this example, if you zoom in so the height is 50, the width will have to be 100 because its 2x the height. They are directly proportional.
Say though, you want to have a 45x60 sprite zoom out so that its width is 15 pixels. You have to use algebra. You would set up this equation:
Also, for zooming in a game, when you zoom out, sprites appear to move more toward the center, and when you zoom in they move away from the center. So say you zoom out to 50% and your current zoom is 100, youll have to have to sprite set its x position to 50% of its xurrent x position, so thats .5 times x position. You'll probaby have to do the same with y position. Say you zoom in to 200% and your current zoom is 50%. You'll have to set the x and y to the difference betweenthe 2, 150%, plus 100%, that's 250%, and if you move the decimal over to the left 2 places, you have to set the x and y to the current x and y position times 2.5
Say though, you want to have a 45x60 sprite zoom out so that its width is 15 pixels. You have to use algebra. You would set up this equation:
45p=15this is saying what percent of 45 pixels equals 15 pixels. So, if you divide 15 by 45, you get .3333333. Then, you move the decimal over 2 places, and you get 33.33333 percent, which rounds to 33%, so if you want the width of 45 pixels to be 15 pixels when zoomed out, you'll have to set the sprite's size to 33%. Then, since the height is proportional, meaning it keeps the dimension, the heigh will turn to 33% of it.
Also, for zooming in a game, when you zoom out, sprites appear to move more toward the center, and when you zoom in they move away from the center. So say you zoom out to 50% and your current zoom is 100, youll have to have to sprite set its x position to 50% of its xurrent x position, so thats .5 times x position. You'll probaby have to do the same with y position. Say you zoom in to 200% and your current zoom is 50%. You'll have to set the x and y to the difference betweenthe 2, 150%, plus 100%, that's 250%, and if you move the decimal over to the left 2 places, you have to set the x and y to the current x and y position times 2.5
Last edited by turkey3 (June 9, 2013 13:44:20)
- kayybee
- Scratcher
1000+ posts
How does zoom actually work?
I don't think you need to explain basic math to the asker. He only wanted to know what the block does, not a review on the math he probably learned years ago…
- freddyfaz7250
- Scratcher
6 posts
How does zoom actually work?
This part helped me out with my game, thanks! Also, for zooming in a game, when you zoom out, sprites appear to move more toward the center, and when you zoom in they move away from the center. So say you zoom out to 50% and your current zoom is 100, youll have to have to sprite set its x position to 50% of its xurrent x position, so thats .5 times x position. You'll probaby have to do the same with y position. Say you zoom in to 200% and your current zoom is 50%. You'll have to set the x and y to the difference betweenthe 2, 150%, plus 100%, that's 250%, and if you move the decimal over to the left 2 places, you have to set the x and y to the current x and y position times 2.5
- GIitchInTheMatrix
- Scratcher
1000+ posts
How does zoom actually work?
Please don’t necropostThis part helped me out with my game, thanks! Also, for zooming in a game, when you zoom out, sprites appear to move more toward the center, and when you zoom in they move away from the center. So say you zoom out to 50% and your current zoom is 100, youll have to have to sprite set its x position to 50% of its xurrent x position, so thats .5 times x position. You'll probaby have to do the same with y position. Say you zoom in to 200% and your current zoom is 50%. You'll have to set the x and y to the difference betweenthe 2, 150%, plus 100%, that's 250%, and if you move the decimal over to the left 2 places, you have to set the x and y to the current x and y position times 2.5
- Discussion Forums
- » Questions about Scratch
- » How does zoom actually work?