Color Picker tool?

id: 750384

category: Help with Scripts

posts: 6

So I'm making an art game and i want to make a color picker/eyedropper tool in the game, anyone know how?
Malicondi Malicondi loading
If you're allowing them to make their own colors, you can use a color detector like this one to get a specific color, or you could have sprites/clones with every color they can pick, and if that sprite/clone is clicked then it will set the color to that, like this:
clone version:
when green flag clicked
hide
set [clone id v] to (0) // clone id has to be "for this sprite only"
repeat (amount of colors)
change [clone id v] by (1)
create clone of [myself v]
end

when I start as a clone
show
go to x:(starting x) y:(starting y) // you can have a list with these positions or manually set them.

when this sprite clicked
if <(clone id) = (1)> then
set [color v] to [red]
// and so on, repeat as necessary.
for sprites have a block like this for every sprite:
when this sprite clicked
set [color v] to (whatever color for this sprite

when gf clicked
show
go to x: (starting x) y: (starting y)
Hope this helps!
-Qlec- -Qlec- loading
You can do it like this:
define detect color
go to [mouse pointer v]
set [color v] to (0)
repeat (32)
repeat (32)
repeat (16)
if <touching color (color)?> then
stop [this script v]
end
change [color v] by (16)
end
change [color v] by (1792)
end
change [color v] by (458752)
end
Make sure the sprite this custom block is in is set to a 1 pixel costume. This works by cycling through all possible colors, checking for each one. To draw it, just do something like this:
... :: hat
set pen color to (color)
pen down
pen up
...
the way i have it is that sliders change the color, how would i do it that way?
If it helps, the
<touching color [#aeb275] ?>
block can output a decimal, so you could check the rgb and black and white values with it (I haven't tried this out for myself yet, and the above solution should work fine, though it might be a bit slower)