# (HELP) Move sense with match color

hello everyone, I’m a beginner. I’m trying to make a project with the simulation being that I have 2 TOP circles, where circle 1 is red and circle 2 is yellow, if the red circle hits the yellow circle, the yellow circle will change color to red. how can i make it like that, does anyone have a reference.

for now I just tried using motionsene from the palette but it didn’t work, because when the red circle doesn’t hit the yellow circle (outside the yellow area) with the position of the red circle I move the color keeps changing. Please advise.
thank you

Hi @of23,

if you know the size and position of each circle, you could calculate their distance and trigger the color change when the distance between them is equal or smaller to the sum of their radiuses.

If there are only 2 circles at all times, you could solve this via color too: As the colors you have chosen are red and yellow (yellow=full red plus full green), you will have to convert them first to monochrome by their luminance and then add them together with the Add TOP. Using a Analyze TOP you can now choose to output the “Maximum Pixel”. The resulting one pixel will have a value of below 1 for the luminance of the yellow circle but when red and yellow are intersecting, the resulting maximum pixel in the Analyze TOP will be 1.
You can convert the pixel from the Analyze TOP via a TOPTo CHOP to CHOPs and here trigger the colorchange.

Have a look at the attached file to see if this makes sense. Main thing to figure out is what you know about the actors in your problem and what solution with this information seems doable.

intersect.toe (5.0 KB)

Cheers
Markus

Thanks Markus for the input and also the examples you have provided.
I think it’s in accordance with the project I’m making. But the problem now is that if I replace it with another image (in the project) it can’t, all I need is to switch the image when the object I move with “Mouse In CHOP” hits the image. maybe you can take a look at the project. please advise. Thank you

intersect_2.12.toe (5.5 KB)

Hi @of23,

sorry for the late reply. One thing to note is that every solution is very particular. So the last one solved for color differences, now your example is using images that have alpha - so we could use the alpha channel - if both overlap, the resulting alpha channel will be > 1 and we can trigger the image change.
There is one first issue to solve: By default all texture processing in TouchDesigner is done using 8bit textures - particular for our case this means that alpha values will be clamped at `1`. We can get around this by changing the `Pixel Format` parameter of the add1 TOP to “16bit float (A)”.
Now we are only processing the alpha channel (preserving some resources) and when adding 2 alphas together, the resulting channel can have a alpha value > 1.
After doing this, we need to instruct the Analyze TOP to analyze the Alpha Channel (`Analyze` parameter) as well as have to change the Threshold TOP’s `RGB` parameter to “Alpha”, the `Comparator` to “Less or Equal” and increase the `Threshold` parameter to “1”.
As a final step, the TopTo CHOP needs to fetch the alpha channel instead of the red channel, so change this one up accordingly.

Example is attached.
intersect_2.13.toe (5.5 KB)

Best
Markus

hallo @snaut

Thanks for the advice, I’ve tried it and it works. thank you very much.

1 Like