---
name: "SDLmm_SRect"
section: "3"
platform: "linux"
package: "libsdl-mm0.1"
version: "0.1.8-4"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/SDLmm_SRect"
---

# SDLmm\_SRect(3)

This enhanced version of SDL\_Rect includes a number of handy short-hand constructors. Since the class is derived from the SDL\_Rect struct, it can be used in any context where an SDL\_Rect is valid.

## NAME

SDLmm::SRect - This enhanced version of **SDL\_Rect includes a number of handy short-hand constructors. Since the class is derived from the SDL\_Rect struct, it can be used in any context where an SDL\_Rect is valid.**

## SYNOPSIS

`#include <sdlmm_srect.h>`

**Inherits SDL\_Rect.**

### Public Methods

**SRect** ()\
 *Default constructor which creates an empty* **SRect** *(xywh variables set to sero).* **SRect** (const SRect &rect)\
 *This is the copy constructor. Simply initializes the value of an* **SRect** *to that of another* **SRect***.* **SRect** (const **SDL\_Rect** &rect)\
 *Constructor which initializes the class from an* **SDL\_Rect** *struct.* **SRect** (const **SPoint** &point)\
 *Constructor which initializes the class from an* **SPoint** *object.* **SRect** (const **SPoint** &upper\_left\_point, const **SPoint** &bottom\_right\_point)\
 *Construct an object using the given upper left and bottom right corners.* **SRect** (const **SPoint** &point, Uint16 nw, Uint16 nh)\
 *Constructor which initializes the class from an* **SPoint** *object and integer values.* **SRect** (Sint16 nx, Sint16 ny, Uint16 nw, Uint16 nh)\
 *Constructor which initializes the class from integer values.* **SRect** (Uint16 nw, Uint16 nh)\
 *Constructor which initializes the width and height from integer values.* SRect& **operator=** (const **SDL\_Rect** &rect)\
 *Set the value of an* **SRect** *to that of an existing* **SDL\_Rect** *or* **SRect***.* bool **operator==** (const **SDL\_Rect** &rect) const\
 *Compare two rectangles for equality.* **SPoint** **GetUpperLeft** () const\
 *Get the coordinates for the upper left corner of the* **SRect***.* **SPoint** **GetUpperRight** () const\
 *Get the coordinates for the upper right corner of the* **SRect***.* **SPoint** **GetBottomLeft** () const\
 *Get the coordinates for the bottom left corner of the* **SRect***.* **SPoint** **GetBottomRight** () const\
 *Get the coordinates for the bottom right corner of the* **SRect***.*

## DETAILED DESCRIPTION

**This enhanced version of SDL\_Rect includes a number of handy short-hand constructors. Since the class is derived from the SDL\_Rect struct, it can be used in any context where an SDL\_Rect is valid.**

**Todo:**  **Extend the class with useful utility functions in regards to rectangles like intersections.**

**Author:**  **David Hedbor \<david@hedbor.org\>**

## CONSTRUCTOR & DESTRUCTOR DOCUMENTATION

### SDLmm::SRect::SRect ()

**Default constructor which creates an empty SRect (xywh variables set to sero).**

### SDLmm::SRect::SRect (const SRect & rect)

**This is the copy constructor. Simply initializes the value of an SRect to that of another SRect.**

**Parameters:**

- *rect*

  *an existing* **SRect** *object.*

### SDLmm::SRect::SRect (const SDL\_Rect & rect)

*Constructor which initializes the class from an* **SDL\_Rect** *struct.*

**Parameters:**

- *rect*

  *an existing* **SDL\_Rect** *struct.*

### SDLmm::SRect::SRect (const SPoint & point)

*Constructor which initializes the class from an* **SPoint** *object.*

*The x and y values will be initialized with the x/y values of the* **SPoint***. h and w will be set to zero.*

**Parameters:**

- *point*

  *reference to an existing* **SPoint** *object.*

### SDLmm::SRect::SRect (const SPoint & upper\_left\_point, const SPoint & bottom\_right\_point)

*Construct an object using the given upper left and bottom right corners.*

**Parameters:**

- *upper\_left\_point*

  **SPoint** *for the upper right corner of the rectangle*

- *bottom\_right\_point*

  **SPoint** *for the bottom right corner of the rectangle*

### SDLmm::SRect::SRect (const SPoint & point, Uint16 nw, Uint16 nh)

*Constructor which initializes the class from an* **SPoint** *object and integer values.*

*The x and y values will be initialized with the x/y values of the* **SPoint** *and the dimensions from nw and nh.*

**Parameters:**

- *nw, nh*

  *the width and height of the rectangle*

- *point*

  *reference to an existing* **SPoint** *object for the upper right corner.*

### SDLmm::SRect::SRect (Sint16 nx, Sint16 ny, Uint16 nw, Uint16 nh)

*Constructor which initializes the class from integer values.*

**Parameters:**

- *nx, ny*

  *position of the upper left corner of the rectangle*

- *nw, nh*

  *the width and height of the rectangle*

### SDLmm::SRect::SRect (Uint16 nw, Uint16 nh)

*Constructor which initializes the width and height from integer values.*

*The x/y coordinates for the upper left corner will be set to zero.*

**Parameters:**

- *nw, nh*

  *the width and height of the rectangle*

## MEMBER FUNCTION DOCUMENTATION

### SPoint SDLmm::SRect::GetBottomLeft () const` [inline]`

*Get the coordinates for the bottom left corner of the* **SRect***.*

**Returns:**  **SPoint** *object*

### SPoint SDLmm::SRect::GetBottomRight () const` [inline]`

*Get the coordinates for the bottom right corner of the* **SRect***.*

**Returns:**  **SPoint** *object*

### SPoint SDLmm::SRect::GetUpperLeft () const` [inline]`

*Get the coordinates for the upper left corner of the* **SRect***.*

**Returns:**  **SPoint** *object*

### SPoint SDLmm::SRect::GetUpperRight () const` [inline]`

*Get the coordinates for the upper right corner of the* **SRect***.*

**Returns:**  **SPoint** *object*

### SRect & SDLmm::SRect::operator= (const SDL\_Rect & rect)` [inline]`

*Set the value of an* **SRect** *to that of an existing* **SDL\_Rect** *or* **SRect***.*

### bool SDLmm::SRect::operator== (const SDL\_Rect & rect) const` [inline]`

*Compare two rectangles for equality.*

**Returns:**  *true if x / y coordinates and h / w are identical in both rectangles.*

## AUTHOR

*Generated automatically by Doxygen for SDLmm from the source code.*
