sdlrect.inc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // based on "sdl_rect.h" (2.24.0)
  2. {**
  3. * \file SDL_rect.h
  4. *
  5. * Header file for SDL_rect definition and management functions.
  6. *}
  7. type
  8. {**
  9. * \brief The structure that defines a point (integer)
  10. *
  11. * \sa SDL_EnclosePoints
  12. * \sa SDL_PointInRect
  13. *}
  14. PPSDL_Point = ^PSDL_Point;
  15. PSDL_Point = ^TSDL_Point;
  16. TSDL_Point = record
  17. x: cint;
  18. y: cint;
  19. end;
  20. {**
  21. * \brief The structure that defines a point (floating point)
  22. *
  23. * \sa SDL_EnclosePoints
  24. * \sa SDL_PointInRect
  25. *}
  26. PPSDL_FPoint = ^PSDL_FPoint;
  27. PSDL_FPoint = ^TSDL_FPoint;
  28. TSDL_FPoint = record
  29. x: cfloat;
  30. y: cfloat;
  31. end;
  32. {**
  33. * \brief A rectangle, with the origin at the upper left (integer).
  34. *
  35. * \sa SDL_RectEmpty
  36. * \sa SDL_RectEquals
  37. * \sa SDL_HasIntersection
  38. * \sa SDL_IntersectRect
  39. * \sa SDL_UnionRect
  40. * \sa SDL_EnclosePoints
  41. *}
  42. PPSDL_Rect = ^PSDL_Rect;
  43. PSDL_Rect = ^TSDL_Rect;
  44. TSDL_Rect = record
  45. x,y: cint;
  46. w,h: cint;
  47. end;
  48. {**
  49. * A rectangle, with the origin at the upper left. (floating point)
  50. *}
  51. PPSDL_FRect = ^PSDL_FRect;
  52. PSDL_FRect = ^TSDL_FRect;
  53. TSDL_FRect = record
  54. x,y: cfloat;
  55. w,h: cfloat;
  56. end;
  57. {**
  58. * Returns true if point resides inside a rectangle.
  59. *}
  60. function SDL_PointInRect(const p: PSDL_Point; const r: PSDL_Rect): Boolean; Inline;
  61. {**
  62. * Returns true if the rectangle has no area.
  63. *}
  64. function SDL_RectEmpty(const r: PSDL_Rect): Boolean; inline;
  65. {**
  66. * Returns true if the two rectangles are equal.
  67. *}
  68. function SDL_RectEquals(const a, b: PSDL_Rect): Boolean; inline;
  69. {**
  70. * Determine whether two rectangles intersect.
  71. *
  72. * SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  73. *}
  74. function SDL_HasIntersection(const a, b: PSDL_Rect): TSDL_Bool; cdecl;
  75. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasIntersection' {$ENDIF} {$ENDIF};
  76. {**
  77. * Calculate the intersection of two rectangles.
  78. *
  79. * SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  80. *}
  81. function SDL_IntersectRect(const A, B: PSDL_Rect; result: PSDL_Rect): TSDL_Bool; cdecl;
  82. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IntersectRect' {$ENDIF} {$ENDIF};
  83. {**
  84. * Calculate the union of two rectangles.
  85. *}
  86. procedure SDL_UnionRect(const A, B: PSDL_Rect; result: PSDL_Rect); cdecl;
  87. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnionRect' {$ENDIF} {$ENDIF};
  88. {**
  89. * Calculate a minimal rectangle enclosing a set of points
  90. *
  91. * SDL_TRUE if any points were within the clipping rect
  92. *}
  93. function SDL_EnclosePoints(const points: PSDL_Point; count: cint; const clip: PSDL_Rect; result: PSDL_Rect): TSDL_Bool; cdecl;
  94. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EnclosePoints' {$ENDIF} {$ENDIF};
  95. {**
  96. * Calculate the intersection of a rectangle and line segment.
  97. *
  98. * SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  99. *}
  100. function SDL_IntersectRectAndLine(const rect: PSDL_Rect; X1, Y1, X2, Y2: pcint): TSDL_Bool; cdecl;
  101. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IntersectRectAndLine' {$ENDIF} {$ENDIF};
  102. {**
  103. * Returns true if point resides inside a rectangle.
  104. *}
  105. function SDL_PointInFRect(const p: PSDL_FPoint; const r: PSDL_FRect): Boolean; Inline;
  106. {**
  107. * Returns true if the rectangle has no area.
  108. *}
  109. function SDL_FRectEmpty(const r: PSDL_FRect): Boolean; inline;
  110. {**
  111. * Returns true if the two rectangles are equal, within some given epsilon.
  112. *
  113. * \since This function is available since SDL 2.0.22.
  114. *}
  115. function SDL_FRectEqualsEpsilon(const a, b: PSDL_FRect; const epsilon: cfloat): Boolean; Inline;
  116. {**
  117. * Returns true if the two rectangles are equal, using a default epsilon.
  118. *
  119. * \since This function is available since SDL 2.0.22.
  120. *}
  121. function SDL_FRectEquals(const a, b: PSDL_FRect): Boolean; Inline;
  122. {**
  123. * Determine whether two rectangles intersect with float precision.
  124. *
  125. * If either pointer is NIL the function will return SDL_FALSE.
  126. *
  127. * \param A an SDL_FRect structure representing the first rectangle
  128. * \param B an SDL_FRect structure representing the second rectangle
  129. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  130. *
  131. * \since This function is available since SDL 2.0.22.
  132. *
  133. * \sa SDL_IntersectRect
  134. *}
  135. function SDL_HasIntersectionF(const a, b: PSDL_FRect): TSDL_Bool; cdecl;
  136. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasIntersectionF' {$ENDIF} {$ENDIF};
  137. {**
  138. * Calculate the intersection of two rectangles with float precision.
  139. *
  140. * If `result` is NIL then this function will return SDL_FALSE.
  141. *
  142. * \param A an SDL_FRect structure representing the first rectangle
  143. * \param B an SDL_FRect structure representing the second rectangle
  144. * \param result an SDL_FRect structure filled in with the intersection of
  145. * rectangles `A` and `B`
  146. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  147. *
  148. * \since This function is available since SDL 2.0.22.
  149. *
  150. * \sa SDL_HasIntersectionF
  151. *}
  152. function SDL_IntersectFRect(const a, b: PSDL_FRect; result: PSDL_FRect): TSDL_Bool; cdecl;
  153. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IntersectFRect' {$ENDIF} {$ENDIF};
  154. {**
  155. * Calculate the union of two rectangles with float precision.
  156. *
  157. * \param A an SDL_FRect structure representing the first rectangle
  158. * \param B an SDL_FRect structure representing the second rectangle
  159. * \param result an SDL_FRect structure filled in with the union of rectangles
  160. * `A` and `B`
  161. *
  162. * \since This function is available since SDL 2.0.22.
  163. *}
  164. function SDL_UnionFRect(const a, b: PSDL_FRect; result: PSDL_FRect): TSDL_Bool; cdecl;
  165. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnionFRect' {$ENDIF} {$ENDIF};
  166. {**
  167. * Calculate a minimal rectangle enclosing a set of points with float
  168. * precision.
  169. *
  170. * If `clip` is not NIL then only points inside of the clipping rectangle
  171. * are considered.
  172. *
  173. * \param points an array of SDL_FPoint structures representing points to be
  174. * enclosed
  175. * \param count the number of structures in the `points` array
  176. * \param clip an SDL_FRect used for clipping or NIL to enclose all points
  177. * \param result an SDL_FRect structure filled in with the minimal enclosing
  178. * rectangle
  179. * \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
  180. * points were outside of the clipping rectangle.
  181. *
  182. * \since This function is available since SDL 2.0.22.
  183. *}
  184. function SDL_EncloseFPoints(const points: PSDL_FPoint; count: cint; const clip: PSDL_FRect; result: PSDL_FRect): TSDL_Bool; cdecl;
  185. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EncloseFPoints' {$ENDIF} {$ENDIF};
  186. {**
  187. * Calculate the intersection of a rectangle and line segment with float
  188. * precision.
  189. *
  190. * This function is used to clip a line segment to a rectangle. A line segment
  191. * contained entirely within the rectangle or that does not intersect will
  192. * remain unchanged. A line segment that crosses the rectangle at either or
  193. * both ends will be clipped to the boundary of the rectangle and the new
  194. * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
  195. *
  196. * \param rect an SDL_FRect structure representing the rectangle to intersect
  197. * \param X1 a pointer to the starting X-coordinate of the line
  198. * \param Y1 a pointer to the starting Y-coordinate of the line
  199. * \param X2 a pointer to the ending X-coordinate of the line
  200. * \param Y2 a pointer to the ending Y-coordinate of the line
  201. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  202. *
  203. * \since This function is available since SDL 2.0.22.
  204. *}
  205. function SDL_IntersectFRectAndLine(const rect: PSDL_FRect; X1, Y1, X2, Y2: pcfloat): TSDL_Bool; cdecl;
  206. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IntersectFRectAndLine' {$ENDIF} {$ENDIF};