Check x&y when they are the correct color

this code prints the word same if the color on coordinates x,y is the same as one of the team colors. how do i check what x and y are at the moment that they are one of the team colors and place a circle there.

int x=1;
int y=1;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.awt.Rectangle;
color ring1 = color(undefined team rgb value);
color ring2 = color(undefined team rgb value);
color ring3 = color(undefined team rgb value);

Robot robot;
void setup() {
  size(1500, 3000);
  try {
    robot = new Robot();
  catch (Exception e) {
void draw() {
  Rectangle r = new Rectangle(y, x, width, height);
  BufferedImage img1 = robot.createScreenCapture(r);
  PImage img2 = new PImage(img1);
  image(img2, 0, 0);
  color colorFromGet = get(x,y);

if ( colorFromGet  == ring1 ){
if ( colorFromGet  == ring2 ){
if ( colorFromGet  == ring3 ){

You may want to add a print statement to tell you what the values of x and y are:

print( "x=" + x + " y=" + y );

You could put this after a print statement that prints “same”, or perhaps right after you get the color.

Also, realize that the points you are checking are (2,2), (3,3), (4,4), (5,5)… etc. This may not be what you want.

Also, the line get(x,y) on its own isn’t doing anything and can be removed.

Also, you might want to put the x++; y++; lines at the end of draw.

Also, check that the Rectangle you are making has the right arguments. Right now, it’s got y first and x second. Perhaps that’s wrong?

Hello @MoonAlien822,

I looks like you are continuing this topic:


i understand the confusion but its not the same thing actually, i used part of that code to make this but its a new program.

This is in all your code examples.

What is this doing in your code?

it was part of my original code before someone suggested another way and i forgot to delete it