Bug in 'stretch' block still here

While testing Joan's use of stretch block, I believe I found a bug. It seems that height of a costume can only be stretched up to 250% and then something strange happens, it moves the sprite to the right and deforms its width - watch video below.

< video deleted >

Link to the code.

Yes I see.
The limit is not 250%, is just when the result is greater than the width/hight of the stage.
So it depends on stage and sprite dimensions.

I write down this in my Todo list (too long now) :slight_smile: to check it.
Thanks,
Joan

Hi @jens!
I see where is the problem.
As you are changing Morphic, I don't submit a PR, but I document it here and explain what I would do...

  • Costume.prototype.stretched creates a new Costume and then, this runs shrinkToFit(this.maxExtent()). So, new stretched costumes can not bigger than Stage dimensions.
  • And, in addition to this limitation, the problem is that Costume center is calculated with the unlimited dimensions.
  • My fastest (and I think fine) solution would be adding a parameter noFit to Costume function. This ensures that it does not damage any other code. In fact, only two lines at objects.js. @jens if you agree this, I'll submit a PR... But maybe you are changing something related...

The idea...

function Costume(canvas, name, rotationCenter, noFit ) {
...
if (!noFit) {this.shrinkToFit(this.maxExtent()); }

and then

Costume.prototype.stretched = function (w, h) {
...
    stretched = new Costume(
        canvas,
        this.name,
        center,
        true
    );

That's all!
Joan

Hi @jguille2, this is another brilliant analysis and a fabulous suggestion how to address this issue, thank you so much! I would welcome your pull-request, as I love your solution. This is not affected by the new Morphic architecture, so your fix would be perfect.

Ok!
PR submitted :slight_smile:
Joan

Yay, thank you, Joan!

Jens's back from vacation, yay! I can see you, @jens