Rect
Definition of a rectangle, with the origin at the upper left.
Operations
- New
- AddH
- AddW
- AddX
- AddY
- GetH
- GetW
- GetX
- GetY
- HasIntersection
- Intersect
- IntersectAndLine
- PointIn
- SetH
- SetW
- SetX
- SetY
- SubH
- SubW
- SubX
- SubY
- ToString
- Union
AddH
Add to current height
method : public : AddH(h:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| h | Int | value to add |
AddW
Add to current width
method : public : AddW(w:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| w | Int | value to add |
AddX
Add to current x position
method : public : AddX(x:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x | Int | value to add |
AddY
Add to current y position
method : public : AddY(y:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| y | Int | value to add |
HasIntersection
Determines if two rectangles intersects
method : public : HasIntersection(B:Rect) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| B | Rect | rectangle to compare |
Return
| Type | Description |
|---|---|
| Bool | true if intersection |
Intersect
Calculate the intersection of two rectangles
method : public : Intersect(B:Rect, result:Rect) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| B | Rect | rectangle to compare |
| result | Rect | Rect filled in with the intersection of rectangles A and B |
Return
| Type | Description |
|---|---|
| Bool | Returns true if there is an intersection, false otherwise. |
IntersectAndLine
Calculate the intersection of a rectangle and line segment
method : public : IntersectAndLine(X1:IntRef, Y1:IntRef, X2:IntRef, Y2:IntRef) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| X1 | IntRef | a holder to the starting X-coordinate of the line |
| Y1 | IntRef | a holder to the starting Y-coordinate of the line |
| X2 | IntRef | a holder to the ending X-coordinate of the line |
| Y2 | IntRef | a holder to the ending Y-coordinate of the line |
Return
| Type | Description |
|---|---|
| Bool | true if there is an intersection, false otherwise |
New
Creates a new rectangle
New(x:Int, y:Int, w:Int, h:Int)Parameters
| Name | Type | Description |
|---|---|---|
| x | Int | x-location |
| y | Int | y-location |
| w | Int | width |
| h | Int | height |
PointIn
Check if a point resides inside a rectangle
method : public : PointIn(p:Point) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| p | Point | an SDL_Point which is the point |
Return
| Type | Description |
|---|---|
| Bool | true if there is an intersection, false otherwise |
SubH
Subtracts from current height
method : public : SubH(h:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| h | Int | value to subtract |
SubW
Subtracts from current width
method : public : SubW(w:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| w | Int | value to subtract |
SubX
Subtracts from current x position
method : public : SubX(x:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x | Int | value to subtract |
SubY
Subtracts from current y position
method : public : SubY(y:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| y | Int | value to subtract |
ToString
String representation of rect
method : public : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string representation |