Discuss Scratch

Epic_Blue_Cat6412
Scratcher
36 posts

Color Picker tool?

So I'm making an art game and i want to make a color picker/eyedropper tool in the game, anyone know how?
Malicondi
Scratcher
1000+ posts

Color Picker tool?

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!

post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.

coming soon :)


-Qlec-
Scratcher
100+ posts

Color Picker tool?

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
...

Last edited by -Qlec- (March 26, 2024 17:59:53)


scratch fact of the day whenever i feel like changing it: Oddly enough, the (item ( ) of list) and (item # of ( ) in list) blocks can be placed where boolean blocks are supposed to go. This calls on the Boolean() function in JavaScript (the language Scratch is coded in), or whatever other boolean coercion method exists. Numbers and booleans behave as expected, with 0 (but, incorrectly, not -0), “” (empty string), and “false” (the string) converting to false. Everything else converts to true, so stuff like NaN seem to be interpreted as strings.
set [foo v] to [something]
forever {
set [foo v] to (join (foo)(foo))
} :: control
Select this, then press Shift + Down











// just your typical code
green is {
an ({apple :: hat #8fd97e}@addInput::ring #55993a) :: #7bc24f cap
}some text<>{
if not (☁ score :: pen) {
{rainbow [#de0909][#ffaa0d][#ffe70a][#7ccf00][#00cf79][#0072cf][#8d00cf] :: #7bc24f reporter}@addInput :: hat pen
}:: #6a8c32
} block [with v] ([text] :: #a8cc5a) ? :: #6a8c32
Epic_Blue_Cat6412
Scratcher
36 posts

Color Picker tool?

here's the project so that you can see:
https://scratch.mit.edu/projects/956938481/

Last edited by Epic_Blue_Cat6412 (March 27, 2024 00:57:50)

Epic_Blue_Cat6412
Scratcher
36 posts

Color Picker tool?

the way i have it is that sliders change the color, how would i do it that way?
MrKingofScratch
Scratcher
100+ posts

Color Picker tool?

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)

Last edited by kaj (Tomorrow 00:00:00)
100th post!

Powered by DjangoBB