19 package Beatmup.Geometry;
25 public int x1, y1, x2, y2;
28 x1 = y1 = x2 = y2 = 0;
31 public IntRectangle(
int centerX,
int centerY,
int size) {
32 x1 = centerX - size/2;
33 y1 = centerY - size/2;
34 x2 = centerX + size/2;
35 y2 = centerY + size/2;
45 public int getWidth() {
49 public int getHeight() {
85 public Rectangle scale(
float x,
float y) {
86 return new Rectangle(x1*x, y1*y, x2*x, y2*y);
106 public static float fit(
int innerWidth,
int innerHeight,
int outerWidth,
int outerHeight) {
107 return innerWidth * outerHeight > innerHeight * outerWidth ?
108 (float) outerWidth / innerWidth : (
float) outerHeight / innerHeight;
113 public String toString() {
114 return "((" + Integer.toString(x1) +
", " + Integer.toString(y1) +
"), (" + Integer.toString(x2) +
", " + Integer.toString(y2) +
"))";
Integer-valued rectangle.
void expand(int border)
Expands / contracts the rectangle.
void makeReal()
Flips rectangle corners so that its size become positive.
void expandTo(int x, int y)
Expands the rectangle so that it have a given point inside or on the boundary.