I am looking for a way (with code) to grab a specific colour in an image and change all the pixels with that colour to a different colour.
Let's say I had a drawing of a 1971 Corvette.
What I want to do is grab every pixel with the red colour, and change it to another colour like maybe orange.
What I tried:
I tried grabbing every pixel and using the map block to change every pixel with that colour to a new colour.
I can't seem to find the right way to do it though. Like what numbers go in the map (list [ ]) block.
If anyone can help me, it would be greatly appreciated. Thank you very much in advance.
do you need to use the fill setting in the costumes maker or is it not a costume
I can probably help.
If you want to change, say, ff0000 into ff7f00, (pure red into pure orange) do you want it to change, say, ff0100 into ff7f00? In other words, what do you want the tolerance to be?
Most likely not a costume:
map ((snip :: list) @addInput :: grey ring) over ([pixels v] of costume (pen trails :: pen) :: looks) :: list reporter
has a (pen trails) block.
here's a simple way to do it
this script is super simple, and in order for this to work, you have to define all color values in rgba.
For example, take your picture, I can turn the blue background completely transparent by doing this
turns into this
and you can see that this way doesn't give you the best results.
Thank you very much. I can do the same thing with the remaining pixels.
Copy the costume (right-click on its picture in the Costumes tab and choose "duplicate"). Edit the copy, and use the paint can icon to floodfill the red parts to whatever color you want. Then you can switch between the two costumes.
Sometimes the fill doesn’t esnt work around edges of costumes even if they are not changing colors.
Sorry. I think you misunderstood. I want to do this with code so I don't need to go through the hassle of duplicating and editing costumes.
Ah, okay, do it ego-lay_atman-bay's way. :~)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.