Hi!
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
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:
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.
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
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:
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.