<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.13"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>My Project: SDL_rect.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">My Project </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.13 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); </script> <div id="main-nav"></div> </div><!-- top --> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="headertitle"> <div class="title">SDL_rect.h</div> </div> </div><!--header--> <div class="contents"> <a href="SDL__rect_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> Simple DirectMedia Layer</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org></span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"></span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> This software is provided 'as-is', without any express or implied</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> warranty. In no event will the authors be held liable for any damages</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> arising from the use of this software.</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"></span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> Permission is granted to anyone to use this software for any purpose,</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> including commercial applications, and to alter it and redistribute it</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> freely, subject to the following restrictions:</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"></span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> 1. The origin of this software must not be misrepresented; you must not</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> claim that you wrote the original software. If you use this software</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> in a product, an acknowledgment in the product documentation would be</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> appreciated but is not required.</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> 2. Altered source versions must be plainly marked as such, and must not be</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> misrepresented as being the original software.</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> 3. This notice may not be removed or altered from any source distribution.</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment">*/</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> </div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#ifndef SDL_rect_h_</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="preprocessor">#define SDL_rect_h_</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#include "<a class="code" href="SDL__stdinc_8h.html">SDL_stdinc.h</a>"</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#include "<a class="code" href="SDL__error_8h.html">SDL_error.h</a>"</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#include "<a class="code" href="SDL__pixels_8h.html">SDL_pixels.h</a>"</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include "<a class="code" href="SDL__rwops_8h.html">SDL_rwops.h</a>"</span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> </div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="preprocessor">#include "<a class="code" href="begin__code_8h.html">begin_code.h</a>"</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">/* Set up for C function definitions, even when using C++ */</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> {</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> </div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="structSDL__Point.html"> 48</a></span> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structSDL__Point.html">SDL_Point</a></div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span> {</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keywordtype">int</span> x;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordtype">int</span> y;</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span> } <a class="code" href="SDL__rect_8h.html#a61e81ca749549bf3b896e6d09f6c0dad">SDL_Point</a>;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> </div><div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="structSDL__Rect.html"> 64</a></span> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structSDL__Rect.html">SDL_Rect</a></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> {</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="keywordtype">int</span> x, y;</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keywordtype">int</span> w, h;</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> } <a class="code" href="SDL__rect_8h.html#ab9e65f8131b4e7faad18d498e7dbde8c">SDL_Rect</a>;</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="SDL__rect_8h.html#a2f9708f2739ef234c34e6feda50b4d2c"> 73</a></span> SDL_FORCE_INLINE SDL_bool <a class="code" href="SDL__rect_8h.html#a2f9708f2739ef234c34e6feda50b4d2c">SDL_PointInRect</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Point.html">SDL_Point</a> *p, <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> *r)</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> {</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">return</span> ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> }</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="SDL__rect_8h.html#aac0e9b5d3f34baec6a2cde95bb01f49c"> 82</a></span> SDL_FORCE_INLINE SDL_bool <a class="code" href="SDL__rect_8h.html#aac0e9b5d3f34baec6a2cde95bb01f49c">SDL_RectEmpty</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> *r)</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span> {</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordflow">return</span> ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span> }</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span> </div><div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="SDL__rect_8h.html#a156979fd3561cf90b87741d11057262a"> 90</a></span> SDL_FORCE_INLINE SDL_bool <a class="code" href="SDL__rect_8h.html#a156979fd3561cf90b87741d11057262a">SDL_RectEquals</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> *a, <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> *b)</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span> {</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keywordflow">return</span> (a && b && (a->x == b->x) && (a->y == b->y) &&</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span> }</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> </div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> <span class="keyword">extern</span> DECLSPEC SDL_bool SDLCALL <a class="code" href="SDL__rect_8h.html#a191ec0b069421d4a36304b475697e847">SDL_HasIntersection</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * A,</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * B);</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> </div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span> <span class="keyword">extern</span> DECLSPEC SDL_bool SDLCALL <a class="code" href="SDL__rect_8h.html#aff8e3dd3b1a25443cd7c8cf02a087290">SDL_IntersectRect</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * A,</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * B,</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * result);</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span> </div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="keyword">extern</span> DECLSPEC <span class="keywordtype">void</span> SDLCALL <a class="code" href="SDL__rect_8h.html#a659f2c25335202888408c95195823f9c">SDL_UnionRect</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * A,</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * B,</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * result);</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span> </div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="keyword">extern</span> DECLSPEC SDL_bool SDLCALL <a class="code" href="SDL__rect_8h.html#afcbb58dbba760b9e6fdb4b5d1ece015c">SDL_EnclosePoints</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Point.html">SDL_Point</a> * points,</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keywordtype">int</span> count,</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * clip,</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <a class="code" href="structSDL__Rect.html">SDL_Rect</a> * result);</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span> </div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span> <span class="keyword">extern</span> DECLSPEC SDL_bool SDLCALL <a class="code" href="SDL__rect_8h.html#acdabdcbeb7b7083f94a092daa26ce069">SDL_IntersectRectAndLine</a>(<span class="keyword">const</span> <a class="code" href="structSDL__Rect.html">SDL_Rect</a> *</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  rect, <span class="keywordtype">int</span> *X1,</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordtype">int</span> *Y1, <span class="keywordtype">int</span> *X2,</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordtype">int</span> *Y2);</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span> </div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span> <span class="comment">/* Ends C function definitions when using C++ */</span></div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span> <span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span> }</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span> <span class="preprocessor">#include "<a class="code" href="close__code_8h.html">close_code.h</a>"</span></div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span> <span class="preprocessor">#endif </span><span class="comment">/* SDL_rect_h_ */</span><span class="preprocessor"></span></div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span> </div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span> <span class="comment">/* vi: set ts=4 sw=4 expandtab: */</span></div><div class="ttc" id="SDL__rect_8h_html_aff8e3dd3b1a25443cd7c8cf02a087290"><div class="ttname"><a href="SDL__rect_8h.html#aff8e3dd3b1a25443cd7c8cf02a087290">SDL_IntersectRect</a></div><div class="ttdeci">DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)</div><div class="ttdoc">Calculate the intersection of two rectangles. </div></div> <div class="ttc" id="SDL__rect_8h_html_a61e81ca749549bf3b896e6d09f6c0dad"><div class="ttname"><a href="SDL__rect_8h.html#a61e81ca749549bf3b896e6d09f6c0dad">SDL_Point</a></div><div class="ttdeci">struct SDL_Point SDL_Point</div><div class="ttdoc">The structure that defines a point. </div></div> <div class="ttc" id="SDL__rect_8h_html_a156979fd3561cf90b87741d11057262a"><div class="ttname"><a href="SDL__rect_8h.html#a156979fd3561cf90b87741d11057262a">SDL_RectEquals</a></div><div class="ttdeci">SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)</div><div class="ttdoc">Returns true if the two rectangles are equal. </div><div class="ttdef"><b>Definition:</b> SDL_rect.h:90</div></div> <div class="ttc" id="begin__code_8h_html"><div class="ttname"><a href="begin__code_8h.html">begin_code.h</a></div></div> <div class="ttc" id="structSDL__Rect_html"><div class="ttname"><a href="structSDL__Rect.html">SDL_Rect</a></div><div class="ttdoc">A rectangle, with the origin at the upper left. </div><div class="ttdef"><b>Definition:</b> SDL_rect.h:64</div></div> <div class="ttc" id="SDL__rwops_8h_html"><div class="ttname"><a href="SDL__rwops_8h.html">SDL_rwops.h</a></div></div> <div class="ttc" id="SDL__rect_8h_html_ab9e65f8131b4e7faad18d498e7dbde8c"><div class="ttname"><a href="SDL__rect_8h.html#ab9e65f8131b4e7faad18d498e7dbde8c">SDL_Rect</a></div><div class="ttdeci">struct SDL_Rect SDL_Rect</div><div class="ttdoc">A rectangle, with the origin at the upper left. </div></div> <div class="ttc" id="SDL__stdinc_8h_html"><div class="ttname"><a href="SDL__stdinc_8h.html">SDL_stdinc.h</a></div></div> <div class="ttc" id="SDL__rect_8h_html_aac0e9b5d3f34baec6a2cde95bb01f49c"><div class="ttname"><a href="SDL__rect_8h.html#aac0e9b5d3f34baec6a2cde95bb01f49c">SDL_RectEmpty</a></div><div class="ttdeci">SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)</div><div class="ttdoc">Returns true if the rectangle has no area. </div><div class="ttdef"><b>Definition:</b> SDL_rect.h:82</div></div> <div class="ttc" id="SDL__rect_8h_html_a2f9708f2739ef234c34e6feda50b4d2c"><div class="ttname"><a href="SDL__rect_8h.html#a2f9708f2739ef234c34e6feda50b4d2c">SDL_PointInRect</a></div><div class="ttdeci">SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)</div><div class="ttdoc">Returns true if point resides inside a rectangle. </div><div class="ttdef"><b>Definition:</b> SDL_rect.h:73</div></div> <div class="ttc" id="close__code_8h_html"><div class="ttname"><a href="close__code_8h.html">close_code.h</a></div></div> <div class="ttc" id="SDL__error_8h_html"><div class="ttname"><a href="SDL__error_8h.html">SDL_error.h</a></div></div> <div class="ttc" id="SDL__pixels_8h_html"><div class="ttname"><a href="SDL__pixels_8h.html">SDL_pixels.h</a></div></div> <div class="ttc" id="structSDL__Point_html"><div class="ttname"><a href="structSDL__Point.html">SDL_Point</a></div><div class="ttdoc">The structure that defines a point. </div><div class="ttdef"><b>Definition:</b> SDL_rect.h:48</div></div> <div class="ttc" id="SDL__rect_8h_html_a659f2c25335202888408c95195823f9c"><div class="ttname"><a href="SDL__rect_8h.html#a659f2c25335202888408c95195823f9c">SDL_UnionRect</a></div><div class="ttdeci">DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)</div><div class="ttdoc">Calculate the union of two rectangles. </div></div> <div class="ttc" id="SDL__rect_8h_html_a191ec0b069421d4a36304b475697e847"><div class="ttname"><a href="SDL__rect_8h.html#a191ec0b069421d4a36304b475697e847">SDL_HasIntersection</a></div><div class="ttdeci">DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect *A, const SDL_Rect *B)</div><div class="ttdoc">Determine whether two rectangles intersect. </div></div> <div class="ttc" id="SDL__rect_8h_html_afcbb58dbba760b9e6fdb4b5d1ece015c"><div class="ttname"><a href="SDL__rect_8h.html#afcbb58dbba760b9e6fdb4b5d1ece015c">SDL_EnclosePoints</a></div><div class="ttdeci">DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result)</div><div class="ttdoc">Calculate a minimal rectangle enclosing a set of points. </div></div> <div class="ttc" id="SDL__rect_8h_html_acdabdcbeb7b7083f94a092daa26ce069"><div class="ttname"><a href="SDL__rect_8h.html#acdabdcbeb7b7083f94a092daa26ce069">SDL_IntersectRectAndLine</a></div><div class="ttdeci">DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2)</div><div class="ttdoc">Calculate the intersection of a rectangle and line segment. </div></div> </div><!-- fragment --></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.13 </small></address> </body> </html>