Discuss Scratch

Skayo
Scratcher
16 posts

"Color touching" - Block

Please add the “Color touching” - Block!
I would be VERY usefull.
It should look something like this:
<color touching>
It outputs the color, the Sprite is currently touching.
To avoid errors, it tests the color at the middle of a Sprite

Here is an example:
when green flag clicked
pen down
turn video [on v]
go to x: (-240) y: (-179)
turn ccw (90) degrees
forever
set pen color to (color touching)
move (1) steps

if <<(y position) = [180]> or <(y position) = [-180]> > then

turn cw (180) degrees
change x by (1)
end

end
With this Script you COULD take a Photo (maybe )

Please add it
Skayo

PS: If you know a Workaround, please post. Thanks

Last edited by Skayo (Feb. 19, 2016 16:25:50)

fredfish10
Scratcher
100+ posts

"Color touching" - Block

<color [#00ff00] is touching [#0000ff] ?><touching color [#ff0088] ?>


use these ^
|
Skayo
Scratcher
16 posts

"Color touching" - Block

fredfish10 wrote:

<color [#00ff00] is touching [#0000ff] ?><touching color [#ff0088] ?>


use these ^
|

Uhm, what do yo mean.

Last edited by Skayo (Feb. 19, 2016 16:28:48)

fredfish10
Scratcher
100+ posts

"Color touching" - Block

I mean that we already have blocks that can solve your problem look at this:


when green flag clicked
forever

if <touching color [#ff0088] ?> then
set [color v] to [pink ]

end

end
MajesticB
Scratcher
500+ posts

"Color touching" - Block

Skayo wrote:

fredfish10 wrote:

<color [#00ff00] is touching [#0000ff] ?><touching color [#ff0088] ?>

Your script works like this:
when green flag clicked
pen down
turn video [on v]
go to x: (-240) y: (-179)
turn ccw (90) degrees
forever
set pen color to <touching color [#ff0088] ?>
move (1) steps

if <<(y position) = [180]> or <(y position) = [-180]> > then

turn cw (180) degrees
change x by (1)
end

end
With this Script you COULD take a Photo (maybe )

Please add it
Skayo

PS: If you know a Workaround, please post. Thanks
alexphan
Scratcher
1000+ posts

"Color touching" - Block

fredfish10 wrote:

I mean that we already have blocks that can solve your problem look at this:


when green flag clicked
forever

if <touching color [#ff0088] ?> then
set [color v] to [pink ]

end

end

But there's millions of colors in the spectrum, so you're not going to put every single possible color into one script, are you?
Sheep_tester
Scratcher
500+ posts

"Color touching" - Block

alexphan wrote:

fredfish10 wrote:

I mean that we already have blocks that can solve your problem look at this:


when green flag clicked
forever

if <touching color [#ff0088] ?> then
set [color v] to [pink ]

end

end

But there's millions of colors in the spectrum, so you're not going to put every single possible color into one script, are you?
Ahem, Scratch's touching color block is not exact…

Anyways support for
(color at x:(0) y:(0)::sensing) // inputs default to sprite's current position
which returns the color in decimal.
Skayo
Scratcher
16 posts

"Color touching" - Block

Sheep_tester wrote:

alexphan wrote:

fredfish10 wrote:

I mean that we already have blocks that can solve your problem look at this:


when green flag clicked
forever

if <touching color [#ff0088] ?> then
set [color v] to [pink ]

end

end

But there's millions of colors in the spectrum, so you're not going to put every single possible color into one script, are you?
Ahem, Scratch's touching color block is not exact…

Anyways support for
(color at x:(0) y:(0)::sensing) // inputs default to sprite's current position
which returns the color in decimal.
Intersesting Block idea! Support
asivi
Scratcher
1000+ posts

"Color touching" - Block

Sheep_tester wrote:

alexphan wrote:

fredfish10 wrote:

I mean that we already have blocks that can solve your problem look at this:


when green flag clicked
forever

if <touching color [#ff0088] ?> then
set [color v] to [pink ]

end

end

But there's millions of colors in the spectrum, so you're not going to put every single possible color into one script, are you?
Ahem, Scratch's touching color block is not exact…

Anyways support for
(color at x:(0) y:(0)::sensing) // inputs default to sprite's current position
which returns the color in decimal.
It works only if the entire costume has the same color in order to detect collision properly.
Yes, there's millions of colors in the spectrum but is supposed that the color to choose is in the stage and you can pick it with the cursor.

Skayo wrote:

Please add the “Color touching” - Block!
I would be VERY usefull.
It should look something like this:
<color touching>
It outputs the color, the Sprite is currently touching.
To avoid errors, it tests the color at the middle of a Sprite

Here is an example:
when green flag clicked
pen down
turn video [on v]
go to x: (-240) y: (-179)
turn ccw (90) degrees
forever
set pen color to (color touching)
move (1) steps

if <<(y position) = [180]> or <(y position) = [-180]> > then

turn cw (180) degrees
change x by (1)
end

end
With this Script you COULD take a Photo (maybe )

Please add it
Skayo

PS: If you know a Workaround, please post. Thanks
If you set the pen color this way you only can set the size pen to 1 if the size is higher than 1 has no sense put your block inside a forever loop moving the pen 1 step.
Regards.

Blobfish_Times
Scratcher
48 posts

"Color touching" - Block

Support. Although there is technically a workaround, it is very slow, and can't detect every color

define color touched
set [color v] to [0]
repeat (32)
repeat (32)
repeat (16)
if <touching color (color) ?> then
set [touchedColor v] to [(color)]
stop [this script v]
end
change [color v] by (16)
end
change [color v] by (1792)
end
change [color v] by (458752)
end

There is also a similar way that involves putting every detectable color in a list.

Last edited by Blobfish_Times (April 6, 2021 16:05:26)

Powered by DjangoBB