Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » i need help on how to make a colour detector
- SpyTheGamer
-
Scratcher
13 posts
i need help on how to make a colour detector
this is the like to the project that shows what i need help on but im just going to explain it all here
The script im looking for is this
if the sprite is a 2 by two or bigger then it mixes all the colour the pixel is touches
The script im looking for is this
when I receive [scan]
scan pixel
define scan pixel
colour detect script here
set [pixelcolour v] to (colour scan result)
set [contrastcolour v] to (contrastscan result)
if the sprite is a 2 by two or bigger then it mixes all the colour the pixel is touches
- EvilPegasus2274
-
Scratcher
16 posts
i need help on how to make a colour detector
Do you mean a color detection script, as in detect a color but not its RGB values, or a color detection script to get its RGB values?
- SpyTheGamer
-
Scratcher
13 posts
i need help on how to make a colour detector
Do you mean a color detection script, as in detect a color but not its RGB values, or a color detection script to get its RGB values?Not RGB values the ones where you use in scratch like these ones where you place a colour value 0-200
set [colour v] effect to (0)
- drmcw
-
Scratcher
1000+ posts
i need help on how to make a colour detector
Look In @DadOMrLog's projects he has a colour scanner that will detect RGB and other projects with more blocks that will convert to the HSL colour space which you want.
Last edited by drmcw (Nov. 11, 2014 20:33:37)
- lafoudre
-
Scratcher
100+ posts
i need help on how to make a colour detector
See project here (not my project):
http://scratch.mit.edu/projects/25078953/#editor
See definition of new blockl “get colors of image” in sprite “scanner”
Actually uses
You have to try all numbers to get the color that is under your sprite. You have to draw a sprite which is just 1 dot X 1 dot
http://scratch.mit.edu/projects/25078953/#editor
See definition of new blockl “get colors of image” in sprite “scanner”
Actually uses
set [some color v] to (123)
if <touching color (some color) ?> then
...
end
You have to try all numbers to get the color that is under your sprite. You have to draw a sprite which is just 1 dot X 1 dot
- SpyTheGamer
-
Scratcher
13 posts
i need help on how to make a colour detector
See project here (not my project):i tried that way but its slow and it im not looking for a new block im looking for a costum block which can scan
http://scratch.mit.edu/projects/25078953/#editor
See definition of new blockl “get colors of image” in sprite “scanner”
Actually usesset [some color v] to (123)
if <touching color (some color) ?> then
...
end
You have to try all numbers to get the color that is under your sprite. You have to draw a sprite which is just 1 dot X 1 dot
- mr-mark
-
Scratcher
34 posts
i need help on how to make a colour detector
I have a recent project that does a ton of color scanning, and you're right, the process can be slow. Through a lot of trial and error, I found some ways to speed it up:
- The sprite you are using to do the scanning should be actual size. If scratch has to shrink a sprite, than that adds to the calculations it does
- Sending colors in the backdrop of the stage is faster than sensing colors on a sprite costume
- You don't have to necessarily test against all 16 million colors of the RGB spectrum. You'll often get a hit if you're close.
- There may be other optimizations you can make depending on what you're trying to do
- ShadowScizor
-
Scratcher
100+ posts
i need help on how to make a colour detector
I have a recent project that does a ton of color scanning, and you're right, the process can be slow. Through a lot of trial and error, I found some ways to speed it up:Thanks a lot! I did't know that I will get I hit as long as it is close enough, there is a time that I really go and test against the 16 million colors and the color I am testing happened to be in the 10 million+ colors, so it took a really long time to scan…
- The sprite you are using to do the scanning should be actual size. If scratch has to shrink a sprite, than that adds to the calculations it does
- Sending colors in the backdrop of the stage is faster than sensing colors on a sprite costume
- You don't have to necessarily test against all 16 million colors of the RGB spectrum. You'll often get a hit if you're close.
- There may be other optimizations you can make depending on what you're trying to do
- mr-mark
-
Scratcher
34 posts
i need help on how to make a colour detector
There is one other optimization I forgot to mention. If you can, make a list of all of the colors that you might encounter. Save that list as part of your project, and then just check against the values in that list. You can make a script to populate the list, but once the list is created, you can save it in the project, and you won't need to run it again. If you are only going to run the script once to populate the list before you share the project, then you can test all 16 million colors.
- SpyTheGamer
-
Scratcher
13 posts
i need help on how to make a colour detector
There is one other optimization I forgot to mention. If you can, make a list of all of the colors that you might encounter. Save that list as part of your project, and then just check against the values in that list. You can make a script to populate the list, but once the list is created, you can save it in the project, and you won't need to run it again. If you are only going to run the script once to populate the list before you share the project, then you can test all 16 million colors.
There is one other optimization I forgot to mention. If you can, make a list of all of the colors that you might encounter. Save that list as part of your project, and then just check against the values in that list. You can make a script to populate the list, but once the list is created, you can save it in the project, and you won't need to run it again. If you are only going to run the script once to populate the list before you share the project, then you can test all 16 million colors.Tnx
- ZoomieJr
-
Scratcher
2 posts
i need help on how to make a colour detector
<key [<key [<key [<<<<<<<(pick random (() - (0)) to (10)) < []> < []> = []> > []> = []> < []> < []> v] pressed?> v] pressed?> v] pressed?>
when this sprite clicked
when backdrop switches to [ v]
when green flag clicked
say []
think [] for (2) secs
hide
switch costume to [ v]
show
switch costume to [ v]
switch costume to [ v]
- mysterious-neutron
-
Scratcher
1000+ posts
i need help on how to make a colour detector
how to delete postPlease do not necropost
- Discussion Forums
- » Help with Scripts
-
» i need help on how to make a colour detector