How to Make Pixels ( = fuzzy equal to certain RGB values) Transparent.

MAP block can be used to make graphical effects (such as pixels' transparency) using fuzzy equality.

See the project below.


Acknowledgments

Without using custom blocks created by KindDavid12 here I would not be able to make this project.

depends%20on%20these%20custom%20looks%20blocks

Could you please add them to your (offical) pixels library? EDIT: Jens made them obsolete.



Wow! That's a fantastic project.

Brian, thanks.

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.

Details

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: Snap! Build Your Own Blocks
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 now 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: accept a list of pixels in the SWITCH TO COSTUME block · jmoenig/Snap@6ff5dcd · GitHub 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?

Screenshot

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!