slashshot007
Active Member
- Joined
- May 6, 2006
- Sythe Gold
- 0
- Messages
- 164
credits to cruel again, i just converted it to java. Winter break really got me bored, so i'm just converting stuff from language to language
.
Code:
public Point FindColorSpiral(Color color, Point StartPoint, Rectangle SearchArea){
//Credits to Cruel for this, SlashShot only converted it to Java
try{
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(SearchArea);
int x = (int)StartPoint.getX() - (int)SearchArea.getX();
int y = (int)StartPoint.getY() - (int)SearchArea.getY();
int direction = 0, length = 1;
int rgbcolor = color.getRGB();
if (rgbcolor == image.getRGB(x, y))
return new Point((int)SearchArea.getX() + x, (int)SearchArea.getY() + y);
while ((x > 2) && (y > 2) && (x < SearchArea.getWidth() - 2) && (y < SearchArea.getHeight() - 2)){
for (int i = 1; i <= length; i++){
switch(direction){
case 0 :
y = y - 1;
break;
case 1 :
x = x + 1;
break;
case 2 :
y = y + 1;
break;
case 3 :
x = x - 1;
break;
}
if (rgbcolor == image.getRGB(x, y))
return new Point((int)SearchArea.getX() + x, (int)SearchArea.getY() + y);
}
direction = (direction + 1) % 4;
if ((direction % 2) == 0)
length = length + 1;
}
return new Point(-1, -1);
}catch(java.awt.AWTException exc) {
return new Point(-1,-1);
}
}

