Beatmup Java package
Beatmup.Geometry.IntRectangle Class Reference

Integer-valued rectangle. More...

Public Member Functions

void expandTo (int x, int y)
 Expands the rectangle so that it have a given point inside or on the boundary. More...
 
void expand (int border)
 Expands / contracts the rectangle. More...
 
void makeReal ()
 Flips rectangle corners so that its size become positive. More...
 

Detailed Description

Integer-valued rectangle.

Definition at line 24 of file IntRectangle.java.

Member Function Documentation

◆ expandTo()

void Beatmup.Geometry.IntRectangle.expandTo ( int  x,
int  y 
)
inline

Expands the rectangle so that it have a given point inside or on the boundary.

Parameters
xhorizontal coordinate of the given point
yhorizontal coordinate of the given point

Definition at line 58 of file IntRectangle.java.

58  {
59  if (x < x1)
60  x1 = x;
61  if (x2 < x)
62  x2 = x;
63  if (y < y1)
64  y1 = y;
65  if (y2 < y)
66  y2 = y;
67  }

◆ expand()

void Beatmup.Geometry.IntRectangle.expand ( int  border)
inline

Expands / contracts the rectangle.

Parameters
borderexpansion size (if negative, contraction)

Definition at line 74 of file IntRectangle.java.

74  {
75  x1 -= border;
76  y1 -= border;
77  x2 += border;
78  y2 += border;
79  }

◆ makeReal()

void Beatmup.Geometry.IntRectangle.makeReal ( )
inline

Flips rectangle corners so that its size become positive.

Definition at line 92 of file IntRectangle.java.

92  {
93  if (x2 < x1) {
94  int swap = x1;
95  x1 = x2;
96  x2 = swap;
97  }
98  if (y2 < y1) {
99  int swap = y1;
100  y1 = y2;
101  y2 = swap;
102  }
103  }

The documentation for this class was generated from the following file: