Discuss Scratch

cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

i want to know, is it possible? is it possible to make a custom block that sets a variable to the color code of the color that the sprite is touching?
deck26
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

Possible but very slow. Much better to limit the range of colours to a small set.
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

u see, im kinda working on a project that gets info from the webcam, and sends it through cloud data. i was thinking of making a thing that detects if its touching a certain color code, and if not, move to a different color code. like this:

if <touching color [1] ?> then 



else
if <touching color [2] ?> then



else

end
end
gtoal
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

finding an arbitrary colour is not the same problem as testing for one in a small list of specific colours. Which is it you need to do?
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

im making something that stored info from the webcam so that it can be stored with cloud data
deck26
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN wrote:

im making something that stored info from the webcam so that it can be stored with cloud data
You've said that. The point remains the same - detecting a small set of colours is still much easier than detecting whatever colour is being touched by your sprite.

Think about the number of pixels and the number of colours. These numbers multiply up very quickly so what numbers are you thinking of?
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

im thinking of something that goes through every possible color code for every pixel on the screen, then gets sent to the server via cloud data, and gets rendered with pen on another computer. kinda like omegle or chat roulette.
deck26
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

i kinda want it to run fast, cause im working on video chat in scratch.
(adjacent color)
gtoal
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN wrote:

i kinda want it to run fast, cause im working on video chat in scratch.
(adjacent color)
Wel, … it won't. It takes minutes per frame. So find something else to work on.
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

meh ill just have it run slow. its better than nothing.
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

what i was thinking of doing was this:

repeat until <(touchingcolor) = [true]>
if <touching color (color) ?> then
set (touchingcolor) to [true]
else
change (color) by (1)
end
end
DaEpikDude
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN wrote:

what i was thinking of doing was this:

repeat until <(touchingcolor) = [true]>
if <touching color (color) ?> then
set (touchingcolor) to [true]
else
change (color) by (1)
end
end
Weeeeeeeeell if you REALLY want to do that it'd take at absolute most 65535 checks to do it.
Better put it in a custom block.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
gtoal
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

If you insist…

look for “image scanner”

https://scratch.mit.edu/search/projects?q=image+scanner
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

DaEpikDude wrote:

cooldude12547REBORN wrote:

what i was thinking of doing was this:

repeat until <(touchingcolor) = [true]>
if <touching color (color) ?> then
set (touchingcolor) to [true]
else
change (color) by (1)
end
end
Weeeeeeeeell if you REALLY want to do that it'd take at absolute most 65535 checks to do it.
Better put it in a custom block.

how long would it be to do 65535 checks? and if its a long time, is there any way to do it quicker?
DaEpikDude
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN wrote:

DaEpikDude wrote:

cooldude12547REBORN wrote:

what i was thinking of doing was this:

repeat until <(touchingcolor) = [true]>
if <touching color (color) ?> then
set (touchingcolor) to [true]
else
change (color) by (1)
end
end
Weeeeeeeeell if you REALLY want to do that it'd take at absolute most 65535 checks to do it.
Better put it in a custom block.

how long would it be to do 65535 checks? and if its a long time, is there any way to do it quicker?
1: A long time.
2: Not unless you want it to be inaccurate and occasionally not work.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
cooldude12547REBORN
Scratcher
16 posts

is there a way to find the color the sprite is touching?

what do u mean by “a long time”? do u mean more than an hour?
DaEpikDude
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

cooldude12547REBORN wrote:

what do u mean by “a long time”? do u mean more than an hour?
Well, not if you put run without screen refresh, but maybe at most like a minute or something?

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
DaEpikDude
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

Note: I actually got it wrong, at maximum it'd run through about 17,000,000 numbers.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
deck26
Scratcher
1000+ posts

is there a way to find the color the sprite is touching?

DaEpikDude wrote:

Note: I actually got it wrong, at maximum it'd run through about 17,000,000 numbers.
Read the topic I linked to, max colours to check is something like 32x 32 x 16. So nowhere near the number you give. Scratch can't recognise that many different colours in a touching block.

Powered by DjangoBB