Swap palete block

add swap palete block, it would be easier to swap paletes in sprites with
[scratchblocks]
switch palete [ff0000] > [0000ff] + :: looks
[/scratchblocks]

wdym???

Is this a feature request? Why is it in Development? And what does it mean?

probly

swap the pallete, one color on the sprite gets switched to another

It is similar to the replace block

yes

I'm kinda surprised none of you know how easy it already is to do this in Snap!.

Costume before:
snap(2)

Run this:


to swap red and blue.

Costume after:
snap

You can use


to capture the modified costume for later use. And if you click the switch to costume script again, you get the original colors back.

Well, so now you have a choice. You can decide to learn something new, or you can decide to be proud of not learning it.

(Sorry, I've been moderating the damn forum all day and I'm grumpy.)

This here forum is supposed to be for people like you to ask questions like that!

So, in this example, we are mapping over the pixels of a costume. Each pixel is a four-item list of red, green, blue, opacity, each in the range [0-255].

The reporter in the first input to map is preloaded libraries script pic. When you give ITEM a list of indices, it reports a list of the items at those positions:


But instead of putting a specific list in ITEM's second input slot, we leave it empty. What MAP does is call that reporter (using the CALL block) repeatedly, with each item of the list of pixels (that is, each pixel individually) filling the input slot. It makes a new list of the same length as the input list, but each item of the new list is the result of calling the reporter (ITEM, in this case) on the corresponding item of the input list.

Simpler example:


Each item of the new list is three more than the corresponding item of the input list.

Does that answer your question? Or are you asking how MAP knows where an empty input slot is in the reporter input? That's just part of the magic of CALL, which really does a lot of complicated stuff. Our hope is that people will be able to understand the metaphor of putting something into an empty box without worrying about how it's implemented. But if the empty slot business is what's keeping you away from MAP, you can instead do this:


giving the gray ring an explicit formal parameter. The result is the same.

If I'm still misunderstanding the question, please try again.

hahaha. I'm not a bot, honest!

Any time you want to modify the items of a list, and you're tempted to write a for each item script, think if you can't use MAP instead. After a while it'll become a habit. :~)

how do you change the color of a certain color on the sprite

thank

Very nice blocks :slight_smile:

thanks :slight_smile:
Also,the color block is actually made by hacking the xml(i need %clr inputs)

That's what I tried to do, but it took about half a second, and I had to do a lot of them, making it too slow. My end solution was to use graphic effects.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.