How to use MAP block to make letters (or other parts of a costume) transparent

Here's a good way to show how the MAP block can be used by students to make interesting graphical effects such as simulating the "green screen" effect (i.e. to make specific colors - in a costume - transparent).

See the project below.

EDIT: I would not be able to make this project without using the following blocks, created and shared by KindDavid12 here.

depends%20on%20these%20custom%20looks%20blocks
Could you please add them to your (offical) pixels library?

Wow! That's a fantastic project.

And this is a fantastic feedback :slight_smile: It makes my heart warm and fuzzy.

Especially because only a year and a half ago, I felt stupid for not being able to understand how MAP block could be used. And today, yay, I got accolades from you, Brian, for using MAP block.

Since then I have been playing with the idea to rename MAP block in order to make it easier to understand for beginners, in the two project below I was wondering if it would be better to rename it GLASSES or MASK:

so, here's a slightly edited version of your project that doesn't rely on the old library blocks and only uses the new primitives: https://snap.berkeley.edu/project?user=jens&project=Media_Map_Transparency_edited_by_jens
The thing we all agree that's not nice is that we're currently overloading the STRETCH block with two different meanings. We're going to change that in the next minor release, I think.

I'm wondering if your solution can skip the intermediate step, which was added, and make it as short as it was, using the slightly redesigned SWITCH TO COSTUME primitive that would, if MAP block was dragged into it, test if the (dragged-in) MAP's result's (i.e. list) length = (stage_size * stage_width) and if each item = a four numbers sized list (between 0 and 255), and in such a case it would allow the MAP's result to be used as costume, because this way kids (and me) could enjoy the MAP block the way this project intended to.

See how visually more elegant it would look like to a kid user, if the SWITCH TO COSTUME primitive allowed for the internal testing, which makes me wonder if it can be labeled with "blessed by Jens" label? :thinking:

more%20elegant_with_SWITCH_redesigned

We need 3 attributes to make a new costume: Pixels, width and height. If you wish to reuse the dimensions of the current costume you can use the new "show picture" block that's left in the "Pixels" library.

Yes, (but) the changed SWITCH primitive could assume that the width and height are equal to the stage's width and height, if the MAP's result's (i.e. list's) length would prove to be equal to width of stage * height of stage, or am I wrong?

interesting idea...

I mean to say that it is not totally an outrageous idea, because the "show picture" block assumes something, too, as you described, it assumes the w*h of current costume, yes?

it could be so that if you pass a list into the SWITCH TO block it would try to distribute its contents into a bitmap of the same dimensions as the current one. That could actually work!

yessss big smile

I like it, great idea!

Just one question. You seem to prefer that the assumed width and height are those of current costume, but in my case the "output" sprite has no costume whatsoever, and thus it would be nicer to assume the stage's width and height providing that the MAP's result's (i.e. list's) length equals to the stage's w*h? Just asking.
EDIT: well, never mind, I could initialize my "output" sprite to have some initial costume. So, basically, it can be your way. Thanks.

yes, this way you can initialize your output sprite any way you like, and the feature would be more versatile, I think, letting you work with multiple different sprites.

@kinestheticlearning: I've just pushed an experimental commit to the Github repo implementing this idea: https://github.com/jmoenig/Snap/commit/6ff5dcd6bb8b1024897554b9a47800bb26347748 so far I like it!

Yay! I feel like a kid waiting to play with an exciting new toy.

Can I try it, using the development version of the Snap! online?

I don't think we've set up the dev stream yet. But you can download the repo and use it offline.

Just another silly question (about downloading repo), because I am not sure if this is it, I made a printscreen below. Is this it?

Yes, "Download ZIP" is fine. (There are other ways too, which is why the UI isn't so obvious.)

We've just released v5.1.1 which includes this feature. It's online now, enjoy!