Skip to content

Instantly share code, notes, and snippets.

@Bradsta
Created October 2, 2012 00:50
Show Gist options
  • Save Bradsta/3815517 to your computer and use it in GitHub Desktop.
Save Bradsta/3815517 to your computer and use it in GitHub Desktop.
Get adjacent points
private Point[] getAdjacentPoints(Point center, int length, int height) {
ArrayList<Point> points = new ArrayList<Point>();
for (int x=(-length); x<=length; x++) {
for (int y=(-height); y<=height; y++) {
points.add(new Point(center.x + x, center.y + y));
}
}
return points.toArray(new Point[points.size()]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment