code static method
Computes the location code according to Cohen-Sutherland, see https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm.
Implementation
static int code(Rectangle r, Mappoint p) {
int code = INSIDE;
if (p.x < r.left) {
// to the left of clip window
code |= LEFT;
} else if (p.x > r.right) {
// to the right of clip window
code |= RIGHT;
}
if (p.y > r.bottom) {
// below the clip window
code |= BOTTOM;
} else if (p.y < r.top) {
// above the clip window
code |= TOP;
}
return code;
}