Page 1 of 1

Scratch bug with sprite scaling

Posted: Wed Mar 30, 2016 6:27 pm
by threepointonefourone
I believe I've found a bug in the latest version of Scratch on the Raspberry Pi. I've compared it with Scratch 1.4 on PC and Scratch 2.0 on PC.

Here's how to replicate it:
- Change the background to the x-y grid (for reference)
- Edit the cat's costume. Add a black dot to the left of the cat.
- Change the costume centre so that it is on this dot.
- Add this script: when green flag clicked / set size to 70% / go to x:0 y:0
- Run the script

What should happen is the black dot should sit on the 0,0 point in the grid, because it's the centre of the sprite and the sprite's position is 0,0. What actually happens is the black dot sits between the 0,0 point and the cat image, which I think means the centre point isn't scaling when the sprite image is. So the sprite is shown at 70%, but the centre point now sits outside the sprite and hasn't scaled. When you run this test on a PC in 1.4 or 2.0, the black dot remains at 0,0 after running the script.

I've got a really cool project that works great on the PC but not on the Pi as a result of this. Please let me know if I've overlooked anything on my end, or if it can be fixed! Thank you for your time!

Re: Scratch bug with sprite scaling

Posted: Wed Mar 30, 2016 11:38 pm
by timrowledge
Some pictures would be really helpful to make sure I completely get what the problem is.

Re: Scratch bug with sprite scaling

Posted: Thu Mar 31, 2016 1:59 pm
by ghp
Hello,
nice topic. Have placed a scratch project to http://heppg.de/rotate_zoom.sb which demonstrates the effect.
On windows scratch 1.4, the black dot == center stays iside the red circle. In scratch on raspberry, the center moves out when zooming; and the next rotation is not around black dot, but around a point where it was before.
Regards,
Gerhard

Re: Scratch bug with sprite scaling

Posted: Thu Mar 31, 2016 5:17 pm
by timrowledge
Gerhard that is a quite lovely demonstration. Thank you!

I see what you mean; clear difference between original MIT 1.4 and current Pi 1.4. That's a surprise since I'm reasonably sure I didn't change anything in that area, but let's see what I can dig up.

Created https://github.com/raspberrypi/scratch/issues/184 to cover this.

Re: Scratch bug with sprite scaling

Posted: Fri Apr 01, 2016 9:17 am
by threepointonefourone
Sorry for the delay - I've been away from the Pi. Thanks for that great demo Gerhard, and to Tim for looking into it.

I've attached here a picture too that shows what happens when the sprite shrinks to less than 100%, where the effect can be even more pronounced. In the picture, the costume centre is the black dot to the left of the cat. When the sprite is scaled to 50%, none of the sprite actually touches its x,y position on the grid and the costume's centre spot is clearly some distance away.

Re: Scratch bug with sprite scaling

Posted: Wed May 18, 2016 4:38 pm
by timrowledge
I haven't given up on this, I'm just swamped! It will be solved...

Re: Scratch bug with sprite scaling

Posted: Wed Jun 08, 2016 5:26 pm
by timrowledge
Fixed it at last. Not because it was terribly complex (any more than any rotate and scale about arbitrary centre work) but because so many things got in the way. Ready for next release!

Re: Scratch bug with sprite scaling

Posted: Sat Sep 17, 2016 8:02 pm
by threepointonefourone
Thank you for fixing this! :-)