/Users/lyon/j4p/src/j2d/examples/BorderMath.java
|
1 package j2d.examples;
2
3 /**
4 * DocJava, Inc. User: lyon Date: Apr 25, 2004
5 * Time: 8:44:49 AM
6 */
7 public class BorderMath {
8 public static void testBorder(int n) {
9 for (int x=-10; x<10; x++){
10 System.out.println(x +"="+wrapX(x, n));
11
12 }
13 }
14
15 public static int wrapX(int x, int n) {
16 if (x>=0) return x%n;
17 //int i = n+x%n;
18 //if (i== n) return 0;
19 return (n+x%n)%n;
20 }
21
22 public static void main(String[] args) {
23 testBorder(6);
24 }
25 }
26