how can i get a larger area of pixels for the Robot class's getPixelColor(x, y) method?
===

my current code, pasted below, will obviously only get the color of the pixels(x, y) 1, 1        2, 2     3, 3 and so on until it finds a color with the same RGB values as targetColor and if it doesnt find a match stop at 1000, 1000 pixels. what is a better way of doing this so i am not only getting the colors of the pixel co ordiantes 1, 1      2, 2 and so on. ?

AND i need to use the getPixelColor(x, y) method because i need the co-ordiantes of the color so i can click the color location.

    import java.awt.Color;
    import java.awt.Robot;

    public class Colour {
        int x, y;    
        int n = 0;
        int m = 0;
        int i = 0;
    
    

    public Colour() {
        try{
            Robot robot = new Robot();
            Color targetColor = new Color(255, 25, 255);
            
            Color color = robot.getPixelColor(n, n);
            
       while(color.getRGB() != targetColor.getRGB() && i != 1000) {           
           color = robot.getPixelColor(n, n);
           System.out.println("color = " + color);
           n++;
           i++;
            
           if(color.getRGB() == targetColor.getRGB()) {
               i = 1000;
               System.out.println("colour found"+ n + " " + n);
           }
           
        } 
            
           
        }catch(Exception e) {
            
        }
        
    }
    
    public static void main(String[] args) {
        Colour color = new Colour();
    }
}






if i was un-clear in what i asked just say and i will try to explain in more depth or a more understandable way. thanks.
