Reading colour under mouse pointer and apply over other player

I'm using Snap! for a couple of years and I realize how can I read the colour under mouse pointer and apply over other player.
In other words I want to apply the same colour from one to other object.
I try with


and similar stuff, but without success.

Can anyone do it?

Thank you a lot!

Create a global variable to store the color under the mouse, then make each object set their color to the color variable.

Hello! Welcome to the forums!

untitled script pic (5)

I got this to change the entire sprite into the RBGA color at the mouse pointer.

Not sure if this is what you're looking for, but just throwing ideas out!

This is totally the right idea, but the costume you're making will be a rectangle filling the entire bounding box of the sprite's original costume; you're losing the costume's shape. Maybe that's okay; @richardsatweb didn't say enough about his project for us to know if shape matters.

In order to preserve the shape, we have to look at the pixels of the original costume and recolor only the ones with a nonzero alpha value:

Alternatively, you can plan ahead by making a costume that's the shape of the original costume but with not-quite-zero color:

and renaming the new costume "mask"; then changing the color is just

I personally would keep the original alpha value, instead overriding it.

Yeah I tried untitled script pic (5) but when I tried it, the costume always ended up black, and I was too lazy to debug it properly. :~(

I got the results I was expecting with this

And for you second method,

Also, after thinking for a while, I now see why it didn't work before. The alpha value at the mouse pointer is 255 (not sure how to get a value that isn't that), which is fully visible. If you replace everything in a costume with [1,1,1,1], then multiply that by rgba at mouuse pointer, the alpha value in each pixel will be 255. However, if you kept in the if, it should theoretically still keep the value if it's 0, because it'll be doing 255*1 or 255*0.

But I do that only for nonzero alpha in the original costume.

I like your first version better than your second; in my second version, the object of the exercise is to avoid using MAP, instead relying entirely on hyper-multiplication.

I do too

In my second one, I just stuck the map in the multiplication block because I didn't want to add the costume. You can just add that as a costume, then multiply the first bit by the pixels of the mask, and it would get the same results.

Also, here's a more elegant way to remove the alpha from the rgba at mouse

I just did my original way because you don't need to know much math to know how it works.

And here's a much more elegant way to do my second method

And if you really don't want to manually rename the costume

(why does the obj_name function not report the renamed obj?)

edit: after looking back at this, I realized a much faster way to get the costume map, just use hyperblocks

Why doesn't SET report the variable's new value? Because it doesn't report, period; it's meant to be used in a sequence of instructions, not in a nesting of function calls.

Why do I want to eliminate the pixel's alpha? I want the mask pixel's alpha to decide whether to color the corresponding pixel in the new costume.

Hello everybody!
Thank you very much for your answers!
ego-lay_atman-bay: I treat with your idea (create a global variable "to store the color under the mouse, then make each object set their color to the color variable") but I can read the RGBA value at mousepointer but I can't apply directly RGBA effect to the object.
I can apply RGBA effect to the object but I can't read it directly from mousepointer.
Here is the project (totally incomplete!) as example:

Happy sharing these community, thank you very very much!

I noticed your mistake. In order for it to work using effects, you have to make the sprite black, then also set the saturation, and brightness in addition to hue (color). Here it is.

The only downside is, you can't have a solid color outline, unless it's a different sprite. You could also go with costume manipulation, which does allow you to have an outline.

Hey ego-lay_atman-bay!
It's so simple!
Thank you very-very-very much!