To get points which lieslie on the border of a rectangle i, I use 4 for-llopsfor loops. At first iI thought about creating RectangleRectangle and using PathItteratorPathItterator, but it confucedconfused me prettyvery much. Is there a better way than mine?
int r = 5; int x = 0; int y = 0; int length = r * 2 + 1; for (int i = 0; i < length; i++) { System.out.print(String.format("(%d,%d) ", x - r + i, y - r)); } System.out.println(); for (int i = 0; i < length; i++) { System.out.print(String.format("(%d,%d) ", x - r + i, y + r)); } System.out.println(); for (int i = 0; i < length; i++) { System.out.print(String.format("(%d,%d) ", x - r , y - r+i)); } System.out.println(); for (int i = 0; i < length; i++) { System.out.print(String.format("(%d,%d) ", x + r , y - r+i)); } System.out.println();