Last active
November 24, 2016 22:44
-
-
Save CalebWhiting/e8aef21dff317f09d40b to your computer and use it in GitHub Desktop.
DTM Sub Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.dang.api.script.methods.DUtils; | |
import org.runedream.api.methods.Game; | |
import java.awt.*; | |
/** | |
* @author Caleb Date: 28/03/12 Time: 15:22 | |
*/ | |
public class DTMSubPoint { | |
/** | |
* @param string "r_g_b_x_y_t" | |
* | |
* @return returns the String converted into a DTMSubPoint | |
*/ | |
public static DTMSubPoint fromString(final String string) { | |
final String[] split = string.split("_"); | |
for (int x = 0; x < split.length; x++) { | |
split[x] = split[x].replaceFirst("_", ""); | |
} | |
final int r = Integer.parseInt(split[0]); | |
final int g = Integer.parseInt(split[1]); | |
final int b = Integer.parseInt(split[2]); | |
final int x = Integer.parseInt(split[3]); | |
final int y = Integer.parseInt(split[4]); | |
final int t = Integer.parseInt(split[5]); | |
return new DTMSubPoint(new Color(r, g, b), x, y, t); | |
} | |
private final Color color; | |
private final int plusX; | |
private final int plusY; | |
private final int tolerance; | |
public DTMSubPoint(final Color color, final int plusX, final int plusY, final int tolerance) { | |
this.color = color; | |
this.plusX = plusX; | |
this.plusY = plusY; | |
this.tolerance = tolerance; | |
} | |
public Color getColor() { | |
return this.color; | |
} | |
public int getPlusX() { | |
return this.plusX; | |
} | |
public int getPlusY() { | |
return this.plusY; | |
} | |
public int getTolerance() { | |
return this.tolerance; | |
} | |
public boolean isAt(final Point mainPoint) { | |
return DUtils.isColor(Game.getColorAt(mainPoint.x + this.getPlusX(), mainPoint.y + this.getPlusY()), this.getColor(), this.getTolerance()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment