Need help making an "Expand/Shrink to Point" block

My idea is that a sprite with any location and any size can cleanly slide into a certain position and size, essentially growing to that location or shrinking to that location, depending on how big it is.

An important requirement is that I want the sprite to finish changing size at the exact moment it arrives at its destination, so I had my block detect the distance, detect the size, calculate the differences between the current state of those variables, and change each of them by 1/20 of the difference.

For example, Sprite A is at 0,0 with a size of 30. I want it to go to 100, 60 with a size of 12. I had my block change the size by (30-12=18)/20 (i chose 20 increments because it seemed smooth enough without overdoing it). I also had it change the x value by (100-0=100)/20, and the y value by (60-0=60)/20.

Doing all of this in one increment, effectively just changing the values without smoothly gliding, works fine. But when I did it in 20 increments, it always ended at the wrong size and position. Here is a link to the project: Snap! Build Your Own Blocks

Try moving to a random location+size, then clicking the big script to see what I mean. How can I fix this?

You mean to be changing SIZE, X, and Y by the same amount each time through the loop, but after the first time, their values have changed, so the increment changes each time.

Thanks so much! I literally made the difference variables to avoid this exact situation, then promptly forgot to use them :man_facepalming:

can you share the project?

The link doesn’t work.

You can simply just search his username up, also, this topic has already been solved. So no further explanation may be needed

I just deleted it, since I got my answer and made the block I wanted. I can just share the greater project that I needed it for, since it has the block in question and much more: Snap! Build Your Own Blocks

The block is called “expand/shrink to fit __ at (,) in __ increments”

okay.