How can I do this real-time? (see post)

I have a project here (only works in edit mode, with normal stage size, with the browser maximized but not fullscreen, on 1920x1080 screen). The only problem, other than those previously mentioned, is that it's extremely sloooooow. Is there a way I can fix that?

Oh, nice!

I tried some experiments to try to speed it up. (Snap! Build Your Own Blocks) Putting a warp around the outer FOR was the only thing that helps, but alas it also makes the results bad.

It would probably help if you could make a snapshot of the whole window and look for colors in there rather than doing the RGBA AT in real time.

I wonder why the stage area comes out gray. Is it trying to smooth the image by averaging the neighbors or something?

I'm thinking of doing that with JS. Pretty much all I have to do on that front is figure out how to get a costume from an HTML canvas.

Edit: Or a morph.

Non-integer coordinates.

Even so, all the neighbors of points near the middle of the stage are white.

About making a costume, I suggest reading the code that runs when you click "pic..." on the stage's context menu.

But that uses IDE_Morph.prototype.saveCanvasAs, and I knew already how to get everything else. I need something more like, say, IDE_Morph.prototype.canvasAsCostume or something, but, as far as I can tell, there is no such thing.

Hmm. There's probably some operating-system-dependent way to do it, but I wouldn't know.

You can get the image of a morph just by using .fullImage(), for example,

stage = world.children[0].stage;
image = stage.fullImage();

This actually returns an html image, so you have to do another step to convert it to a costume, just do this

return new Costume(image, 'costume name')

And a full example

stage = world.children[0].stage;
image = stage.fullImage();
cst = new Costume(image, 'test');
return cst

Note: this works on any morph, not just the stage.

I figured that out:

return new Costume(this.parentThatIsA(IDE_Morph).fullImage());

but that doesn't seem to show menus:

With expression extracted outside of the loop I've got 1.5 x speedup (single line from 220 to 130ms)


.
To get the image of the whole window not only the stage
return new Costume( world.worldCanvas, 'world');

Ooh I like the recursive stages!

Ha!

Edit: getIDEImage

Edit 2:

What's the star for?

I'm going to try that...

Edit: Yay!

Oh, that is a beautiful project, thank you!!

Which one? The pure-Snap! one or the one that uses JS?

the pure Snap! one, because it's simple, elegant, and beautiful. Yes, it's slow, but the surprise ist great! I love it.

Unfortunately, it only works properly in the conditions described:

Jens will now figure out the minimum change to Snap! that would allow your project to be fast and work everywhere, and he'll implement it. :~)

image
hehehe panorama effect

Probably the minimum change would be a PRIMITIVE extension that gives you the IDE's origin and extent (or the world's).

Ha ha! I saw that too.