zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_rect.c File Reference
#include "SDL_config.h"
#include "SDL_rect.h"
#include "SDL_rect_c.h"

Go to the source code of this file.

Macros

#define CODE_BOTTOM   1
 
#define CODE_LEFT   4
 
#define CODE_RIGHT   8
 
#define CODE_TOP   2
 

Functions

static int ComputeOutCode (const SDL_Rect *rect, int x, int y)
 
SDL_bool SDL_EnclosePoints (const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result)
 Calculate a minimal rectangle enclosing a set of points. More...
 
SDL_bool SDL_GetSpanEnclosingRect (int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span)
 
SDL_bool SDL_HasIntersection (const SDL_Rect *A, const SDL_Rect *B)
 Determine whether two rectangles intersect. More...
 
SDL_bool SDL_IntersectRect (const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
 Calculate the intersection of two rectangles. More...
 
SDL_bool SDL_IntersectRectAndLine (const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2)
 Calculate the intersection of a rectangle and line segment. More...
 
void SDL_UnionRect (const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
 Calculate the union of two rectangles. More...
 

Macro Definition Documentation

#define CODE_BOTTOM   1

Definition at line 294 of file SDL_rect.c.

Referenced by ComputeOutCode(), and SDL_IntersectRectAndLine().

#define CODE_LEFT   4

Definition at line 296 of file SDL_rect.c.

Referenced by ComputeOutCode(), and SDL_IntersectRectAndLine().

#define CODE_RIGHT   8

Definition at line 297 of file SDL_rect.c.

Referenced by ComputeOutCode(), and SDL_IntersectRectAndLine().

#define CODE_TOP   2

Definition at line 295 of file SDL_rect.c.

Referenced by ComputeOutCode(), and SDL_IntersectRectAndLine().

Function Documentation

static int ComputeOutCode ( const SDL_Rect rect,
int  x,
int  y 
)
static
SDL_bool SDL_EnclosePoints ( const SDL_Point points,
int  count,
const SDL_Rect clip,
SDL_Rect result 
)

Calculate a minimal rectangle enclosing a set of points.

Returns
SDL_TRUE if any points were within the clipping rect

Definition at line 192 of file SDL_rect.c.

References SDL_Rect::h, i, NULL, SDL_FALSE, SDL_InvalidParamError, SDL_RectEmpty(), SDL_TRUE, SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Point::y, and SDL_Rect::y.

Referenced by SDL_GetWindowDisplayIndex().

SDL_bool SDL_GetSpanEnclosingRect ( int  width,
int  height,
int  numrects,
const SDL_Rect rects,
SDL_Rect span 
)
SDL_bool SDL_HasIntersection ( const SDL_Rect A,
const SDL_Rect B 
)

Determine whether two rectangles intersect.

Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.

Definition at line 28 of file SDL_rect.c.

References SDL_Rect::h, SDL_FALSE, SDL_InvalidParamError, SDL_RectEmpty(), SDL_TRUE, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_RenderCopy().

SDL_bool SDL_IntersectRect ( const SDL_Rect A,
const SDL_Rect B,
SDL_Rect result 
)

Calculate the intersection of two rectangles.

Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.

Definition at line 75 of file SDL_rect.c.

References SDL_Rect::h, SDL_FALSE, SDL_InvalidParamError, SDL_RectEmpty(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_BlendFillRect(), SDL_BlendFillRects(), SDL_FillRect(), SDL_LowerBlitScaled(), SDL_RenderCopy(), SDL_RenderCopyEx(), SDL_RenderReadPixels(), and SDL_SetClipRect().

SDL_bool SDL_IntersectRectAndLine ( const SDL_Rect rect,
int X1,
int Y1,
int X2,
int Y2 
)

Calculate the intersection of a rectangle and line segment.

Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.

Definition at line 316 of file SDL_rect.c.

References CODE_BOTTOM, CODE_LEFT, CODE_RIGHT, CODE_TOP, ComputeOutCode(), SDL_Rect::h, SDL_FALSE, SDL_InvalidParamError, SDL_RectEmpty(), SDL_TRUE, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_BlendLine(), SDL_BlendLines(), SDL_DrawLine(), and SDL_DrawLines().

void SDL_UnionRect ( const SDL_Rect A,
const SDL_Rect B,
SDL_Rect result 
)

Calculate the union of two rectangles.

Definition at line 129 of file SDL_rect.c.

References SDL_Rect::h, SDL_InvalidParamError, SDL_RectEmpty(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.