summaryrefslogtreecommitdiff
path: root/doc/html/Shape_8cpp-source.htm
blob: eb01e8d90d3a868121105550ce13c4152d64c552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="tabs.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="logo">
            <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" />
        </div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.htm"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.htm"><span>Namespaces</span></a></li>
      <li><a href="annotated.htm"><span>Classes</span></a></li>
      <li class="current"><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.htm"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>Shape.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// SFML - Simple and Fast Multimedia Library</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span>
<a name="l00007"></a>00007 <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00010"></a>00010 <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span>
<a name="l00011"></a>00011 <span class="comment">// subject to the following restrictions:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// 1. The origin of this software must not be misrepresented;</span>
<a name="l00014"></a>00014 <span class="comment">//    you must not claim that you wrote the original software.</span>
<a name="l00015"></a>00015 <span class="comment">//    If you use this software in a product, an acknowledgment</span>
<a name="l00016"></a>00016 <span class="comment">//    in the product documentation would be appreciated but is not required.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// 2. Altered source versions must be plainly marked as such,</span>
<a name="l00019"></a>00019 <span class="comment">//    and must not be misrepresented as being the original software.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00022"></a>00022 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">// Headers</span>
<a name="l00028"></a>00028 <span class="comment"></span><span class="preprocessor">#include &lt;SFML/Graphics/Shape.hpp&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;SFML/Graphics/GraphicsContext.hpp&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>sf
<a name="l00034"></a>00034 {
<a name="l00038"></a><a class="code" href="classsf_1_1Shape.htm#413a457f720835b9f5d8e97ca8b80960">00038</a> <a class="code" href="classsf_1_1Shape.htm#413a457f720835b9f5d8e97ca8b80960" title="Default constructor.">Shape::Shape</a>() :
<a name="l00039"></a>00039 myOutline         (0.f),
<a name="l00040"></a>00040 myIsFillEnabled   (true),
<a name="l00041"></a>00041 myIsOutlineEnabled(true),
<a name="l00042"></a>00042 myIsCompiled      (false)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044     <span class="comment">// Put a placeholder for the center of the shape</span>
<a name="l00045"></a>00045     myPoints.push_back(Point());
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 
<a name="l00052"></a><a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92">00052</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">Shape::AddPoint</a>(<span class="keywordtype">float</span> X, <span class="keywordtype">float</span> Y, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054     <a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(X, Y), Col, OutlineCol);
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 
<a name="l00061"></a><a class="code" href="classsf_1_1Shape.htm#212f5b1d630e820989a53dcbf46d33e4">00061</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">Shape::AddPoint</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; Position, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063     myPoints.push_back(Point(Position, Col, OutlineCol));
<a name="l00064"></a>00064     myIsCompiled = <span class="keyword">false</span>;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 
<a name="l00071"></a><a class="code" href="classsf_1_1Shape.htm#8bafa82b4f42937d897c5c5aecd22350">00071</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classsf_1_1Shape.htm#8bafa82b4f42937d897c5c5aecd22350" title="Get the number of points composing the shape.">Shape::GetNbPoints</a>()<span class="keyword"> const</span>
<a name="l00072"></a>00072 <span class="keyword"></span>{
<a name="l00073"></a>00073     <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">&gt;</span>(myPoints.size() - 1);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00081"></a><a class="code" href="classsf_1_1Shape.htm#6370770e5f1d1c1b1abfeef80d6296ae">00081</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#6370770e5f1d1c1b1abfeef80d6296ae" title="Enable or disable filling the shape.">Shape::EnableFill</a>(<span class="keywordtype">bool</span> Enable)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083     myIsFillEnabled = Enable;
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086 
<a name="l00091"></a><a class="code" href="classsf_1_1Shape.htm#f65abf11c7faa1a78c6d203e68a35a26">00091</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#f65abf11c7faa1a78c6d203e68a35a26" title="Enable or disable drawing the shape outline.">Shape::EnableOutline</a>(<span class="keywordtype">bool</span> Enable)
<a name="l00092"></a>00092 {
<a name="l00093"></a>00093     myIsOutlineEnabled = Enable;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 
<a name="l00100"></a><a class="code" href="classsf_1_1Shape.htm#f3eaee50b3af95d9884b41fc3996567e">00100</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#f3eaee50b3af95d9884b41fc3996567e" title="Set the position of a point.">Shape::SetPointPosition</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index, <span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; Position)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     myPoints[Index + 1].Position = Position;
<a name="l00103"></a>00103     myIsCompiled = <span class="keyword">false</span>;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 
<a name="l00110"></a><a class="code" href="classsf_1_1Shape.htm#e3000e995446507929c24b3abbcce18c">00110</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#f3eaee50b3af95d9884b41fc3996567e" title="Set the position of a point.">Shape::SetPointPosition</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index, <span class="keywordtype">float</span> X, <span class="keywordtype">float</span> Y)
<a name="l00111"></a>00111 {
<a name="l00112"></a>00112     <a class="code" href="classsf_1_1Shape.htm#f3eaee50b3af95d9884b41fc3996567e" title="Set the position of a point.">SetPointPosition</a>(Index, <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(X, Y));
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 
<a name="l00119"></a><a class="code" href="classsf_1_1Shape.htm#d55eab90a2fb9fd0bcc1dd695b0bc769">00119</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#d55eab90a2fb9fd0bcc1dd695b0bc769" title="Set the color of a point.">Shape::SetPointColor</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121     myPoints[Index + 1].Col = Col;
<a name="l00122"></a>00122     myIsCompiled = <span class="keyword">false</span>;
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 
<a name="l00129"></a><a class="code" href="classsf_1_1Shape.htm#d28205b9e4784ae0adcc2209669572fe">00129</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#d28205b9e4784ae0adcc2209669572fe" title="Set the outline color of a point.">Shape::SetPointOutlineColor</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131     myPoints[Index + 1].OutlineCol = OutlineCol;
<a name="l00132"></a>00132     myIsCompiled = <span class="keyword">false</span>;
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 
<a name="l00139"></a><a class="code" href="classsf_1_1Shape.htm#77ce4ef6cf1944768b2bc88c98a98b65">00139</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#77ce4ef6cf1944768b2bc88c98a98b65" title="Change the width of the shape outline.">Shape::SetOutlineWidth</a>(<span class="keywordtype">float</span> Width)
<a name="l00140"></a>00140 {
<a name="l00141"></a>00141     myOutline = Width;
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 
<a name="l00148"></a><a class="code" href="classsf_1_1Shape.htm#2b3cf65f5453a84466f749b97e611436">00148</a> <span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; <a class="code" href="classsf_1_1Shape.htm#2b3cf65f5453a84466f749b97e611436" title="Get the position of a point.">Shape::GetPointPosition</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index)<span class="keyword"> const</span>
<a name="l00149"></a>00149 <span class="keyword"></span>{
<a name="l00150"></a>00150     <span class="keywordflow">return</span> myPoints[Index + 1].Position;
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 
<a name="l00157"></a><a class="code" href="classsf_1_1Shape.htm#f22db94719a2e359cb02dd4108e6ea92">00157</a> <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; <a class="code" href="classsf_1_1Shape.htm#f22db94719a2e359cb02dd4108e6ea92" title="Get the color of a point.">Shape::GetPointColor</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index)<span class="keyword"> const</span>
<a name="l00158"></a>00158 <span class="keyword"></span>{
<a name="l00159"></a>00159     <span class="keywordflow">return</span> myPoints[Index + 1].Col;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161 
<a name="l00162"></a>00162 
<a name="l00166"></a><a class="code" href="classsf_1_1Shape.htm#f9a40ea9b28f96f183533991e6f811b8">00166</a> <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; <a class="code" href="classsf_1_1Shape.htm#f9a40ea9b28f96f183533991e6f811b8" title="Get the outline color of a point.">Shape::GetPointOutlineColor</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Index)<span class="keyword"> const</span>
<a name="l00167"></a>00167 <span class="keyword"></span>{
<a name="l00168"></a>00168     <span class="keywordflow">return</span> myPoints[Index + 1].OutlineCol;
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 
<a name="l00175"></a><a class="code" href="classsf_1_1Shape.htm#ed31da968d6d4bc8f6a3b4bf808c1087">00175</a> <span class="keywordtype">float</span> <a class="code" href="classsf_1_1Shape.htm#ed31da968d6d4bc8f6a3b4bf808c1087" title="Get the width of the shape outline.">Shape::GetOutlineWidth</a>()<span class="keyword"> const</span>
<a name="l00176"></a>00176 <span class="keyword"></span>{
<a name="l00177"></a>00177     <span class="keywordflow">return</span> myOutline;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 
<a name="l00180"></a>00180 
<a name="l00184"></a><a class="code" href="classsf_1_1Shape.htm#90fe51b17c8029ed528d8590595a3f1f">00184</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#90fe51b17c8029ed528d8590595a3f1f" title="Create a shape made of a single line (use floats).">Shape::Line</a>(<span class="keywordtype">float</span> P1X, <span class="keywordtype">float</span> P1Y, <span class="keywordtype">float</span> P2X, <span class="keywordtype">float</span> P2Y, <span class="keywordtype">float</span> Thickness, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186     <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a> P1(P1X, P1Y);
<a name="l00187"></a>00187     <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a> P2(P2X, P2Y);
<a name="l00188"></a>00188 
<a name="l00189"></a>00189     <span class="comment">// Compute the extrusion direction</span>
<a name="l00190"></a>00190     <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a> Normal;
<a name="l00191"></a>00191     ComputeNormal(P1, P2, Normal);
<a name="l00192"></a>00192     Normal *= Thickness / 2;
<a name="l00193"></a>00193 
<a name="l00194"></a>00194     <span class="comment">// Create the shape's points</span>
<a name="l00195"></a>00195     <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> S;
<a name="l00196"></a>00196     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(P1 - Normal, Col, OutlineCol);
<a name="l00197"></a>00197     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(P2 - Normal, Col, OutlineCol);
<a name="l00198"></a>00198     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(P2 + Normal, Col, OutlineCol);
<a name="l00199"></a>00199     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(P1 + Normal, Col, OutlineCol);
<a name="l00200"></a>00200     S.<a class="code" href="classsf_1_1Shape.htm#77ce4ef6cf1944768b2bc88c98a98b65" title="Change the width of the shape outline.">SetOutlineWidth</a>(Outline);
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="comment">// Compile it</span>
<a name="l00203"></a>00203     S.<a class="code" href="classsf_1_1Shape.htm#b51218d7bcc5444b81de34afd31c4c33" title="Compile the shape : compute its center and its outline.">Compile</a>();
<a name="l00204"></a>00204 
<a name="l00205"></a>00205     <span class="keywordflow">return</span> S;
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 
<a name="l00208"></a>00208 
<a name="l00212"></a><a class="code" href="classsf_1_1Shape.htm#264e5374cac72a520fcf69c3bbdfe688">00212</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#90fe51b17c8029ed528d8590595a3f1f" title="Create a shape made of a single line (use floats).">Shape::Line</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; P1, <span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; P2, <span class="keywordtype">float</span> Thickness, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214     <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Shape.htm#90fe51b17c8029ed528d8590595a3f1f" title="Create a shape made of a single line (use floats).">Shape::Line</a>(P1.<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>, P1.<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>, P2.<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>, P2.<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>, Thickness, Col, Outline, OutlineCol);
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 
<a name="l00217"></a>00217 
<a name="l00221"></a><a class="code" href="classsf_1_1Shape.htm#aec9c0468a77871f6410aea757105498">00221</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#aec9c0468a77871f6410aea757105498" title="Create a shape made of a single rectangle (use floats).">Shape::Rectangle</a>(<span class="keywordtype">float</span> P1X, <span class="keywordtype">float</span> P1Y, <span class="keywordtype">float</span> P2X, <span class="keywordtype">float</span> P2Y, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00222"></a>00222 {
<a name="l00223"></a>00223     <span class="comment">// Create the shape's points</span>
<a name="l00224"></a>00224     <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> S;
<a name="l00225"></a>00225     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(P1X, P1Y), Col, OutlineCol);
<a name="l00226"></a>00226     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(P2X, P1Y), Col, OutlineCol);
<a name="l00227"></a>00227     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(P2X, P2Y), Col, OutlineCol);
<a name="l00228"></a>00228     S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(P1X, P2Y), Col, OutlineCol);
<a name="l00229"></a>00229     S.<a class="code" href="classsf_1_1Shape.htm#77ce4ef6cf1944768b2bc88c98a98b65" title="Change the width of the shape outline.">SetOutlineWidth</a>(Outline);
<a name="l00230"></a>00230 
<a name="l00231"></a>00231     <span class="comment">// Compile it</span>
<a name="l00232"></a>00232     S.<a class="code" href="classsf_1_1Shape.htm#b51218d7bcc5444b81de34afd31c4c33" title="Compile the shape : compute its center and its outline.">Compile</a>();
<a name="l00233"></a>00233 
<a name="l00234"></a>00234     <span class="keywordflow">return</span> S;
<a name="l00235"></a>00235 }
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 
<a name="l00241"></a><a class="code" href="classsf_1_1Shape.htm#7273d55fb2e6ede4d901428a97579169">00241</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#aec9c0468a77871f6410aea757105498" title="Create a shape made of a single rectangle (use floats).">Shape::Rectangle</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; P1, <span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; P2, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00242"></a>00242 {
<a name="l00243"></a>00243     <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Shape.htm#aec9c0468a77871f6410aea757105498" title="Create a shape made of a single rectangle (use floats).">Shape::Rectangle</a>(P1.<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>, P1.<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>, P2.<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>, P2.<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>, Col, Outline, OutlineCol);
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 
<a name="l00250"></a><a class="code" href="classsf_1_1Shape.htm#10ccaef12679a28cf4d3003fceffc2f0">00250</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#10ccaef12679a28cf4d3003fceffc2f0" title="Create a shape made of a single circle (use floats).">Shape::Circle</a>(<span class="keywordtype">float</span> X, <span class="keywordtype">float</span> Y, <span class="keywordtype">float</span> Radius, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00251"></a>00251 {
<a name="l00252"></a>00252     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> NbSegments = 40;
<a name="l00253"></a>00253 
<a name="l00254"></a>00254     <span class="comment">// Create the points set</span>
<a name="l00255"></a>00255     <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> S;
<a name="l00256"></a>00256     <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a> Center(X, Y);
<a name="l00257"></a>00257     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; NbSegments; ++i)
<a name="l00258"></a>00258     {
<a name="l00259"></a>00259         <span class="keywordtype">float</span> Angle = i * 2 * 3.141592654f / NbSegments;
<a name="l00260"></a>00260         <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a> Offset(cos(Angle), sin(Angle));
<a name="l00261"></a>00261 
<a name="l00262"></a>00262         S.<a class="code" href="classsf_1_1Shape.htm#b28fab6a7d2b596f15ef5c0611341c92" title="Add a point to the shape.">AddPoint</a>(Center + Offset * Radius, Col, OutlineCol);
<a name="l00263"></a>00263     }
<a name="l00264"></a>00264 
<a name="l00265"></a>00265     <span class="comment">// Compile it</span>
<a name="l00266"></a>00266     S.<a class="code" href="classsf_1_1Shape.htm#77ce4ef6cf1944768b2bc88c98a98b65" title="Change the width of the shape outline.">SetOutlineWidth</a>(Outline);
<a name="l00267"></a>00267     S.<a class="code" href="classsf_1_1Shape.htm#b51218d7bcc5444b81de34afd31c4c33" title="Compile the shape : compute its center and its outline.">Compile</a>();
<a name="l00268"></a>00268 
<a name="l00269"></a>00269     <span class="keywordflow">return</span> S;
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271 
<a name="l00272"></a>00272 
<a name="l00276"></a><a class="code" href="classsf_1_1Shape.htm#b7b5082c253cf624b76de040f9c017d4">00276</a> <a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a> <a class="code" href="classsf_1_1Shape.htm#10ccaef12679a28cf4d3003fceffc2f0" title="Create a shape made of a single circle (use floats).">Shape::Circle</a>(<span class="keyword">const</span> <a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>&amp; Center, <span class="keywordtype">float</span> Radius, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; Col, <span class="keywordtype">float</span> Outline, <span class="keyword">const</span> <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>&amp; OutlineCol)
<a name="l00277"></a>00277 {
<a name="l00278"></a>00278     <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Shape.htm#10ccaef12679a28cf4d3003fceffc2f0" title="Create a shape made of a single circle (use floats).">Shape::Circle</a>(Center.<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>, Center.<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>, Radius, Col, Outline, OutlineCol);
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 
<a name="l00285"></a><a class="code" href="classsf_1_1Shape.htm#b32d683b125efd3bd7ccf878b1f50a31">00285</a> <span class="keywordtype">void</span> <a class="code" href="classsf_1_1Shape.htm#b32d683b125efd3bd7ccf878b1f50a31" title="/see Drawable::Render">Shape::Render</a>(<a class="code" href="classsf_1_1RenderTarget.htm" title="Base class for all render targets (window, image, .">RenderTarget</a>&amp;)<span class="keyword"> const</span>
<a name="l00286"></a>00286 <span class="keyword"></span>{
<a name="l00287"></a>00287     <span class="comment">// Make sure the shape has at least 3 points (4 if we count the center)</span>
<a name="l00288"></a>00288     <span class="keywordflow">if</span> (myPoints.size() &lt; 4)
<a name="l00289"></a>00289         <span class="keywordflow">return</span>;
<a name="l00290"></a>00290 
<a name="l00291"></a>00291     <span class="comment">// Make sure the shape is compiled</span>
<a name="l00292"></a>00292     <span class="keywordflow">if</span> (!myIsCompiled)
<a name="l00293"></a>00293         <span class="keyword">const_cast&lt;</span><a class="code" href="classsf_1_1Shape.htm" title="Shape defines a drawable convex shape ; it also defines helper functions to draw...">Shape</a>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;Compile();
<a name="l00294"></a>00294 
<a name="l00295"></a>00295     <span class="comment">// Shapes only use color, no texture</span>
<a name="l00296"></a>00296     GLCheck(glDisable(GL_TEXTURE_2D));
<a name="l00297"></a>00297 
<a name="l00298"></a>00298     <span class="comment">// Draw the shape</span>
<a name="l00299"></a>00299     <span class="keywordflow">if</span> (myIsFillEnabled)
<a name="l00300"></a>00300     {
<a name="l00301"></a>00301         glBegin(GL_TRIANGLE_FAN);
<a name="l00302"></a>00302         {
<a name="l00303"></a>00303             <span class="keywordflow">for</span> (std::vector&lt;Point&gt;::const_iterator i = myPoints.begin(); i != myPoints.end(); ++i)
<a name="l00304"></a>00304             {
<a name="l00305"></a>00305                 <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a> PointColor = i-&gt;Col * <a class="code" href="classsf_1_1Drawable.htm#a2a028c4a975b5ed6d5a560a1c44e0c8" title="Get the color of the object.">GetColor</a>();
<a name="l00306"></a>00306                 glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00307"></a>00307                 glVertex2f(i-&gt;Position.x, i-&gt;Position.y);
<a name="l00308"></a>00308             }
<a name="l00309"></a>00309 
<a name="l00310"></a>00310             <span class="comment">// Close the shape by duplicating the first point at the end</span>
<a name="l00311"></a>00311             <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a> PointColor = myPoints[1].Col * <a class="code" href="classsf_1_1Drawable.htm#a2a028c4a975b5ed6d5a560a1c44e0c8" title="Get the color of the object.">GetColor</a>();
<a name="l00312"></a>00312             glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00313"></a>00313             glVertex2f(myPoints[1].Position.x, myPoints[1].Position.y);
<a name="l00314"></a>00314         }
<a name="l00315"></a>00315         glEnd();
<a name="l00316"></a>00316     }
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <span class="comment">// Draw the outline</span>
<a name="l00319"></a>00319     <span class="keywordflow">if</span> (myIsOutlineEnabled)
<a name="l00320"></a>00320     {
<a name="l00321"></a>00321         glBegin(GL_TRIANGLE_STRIP);
<a name="l00322"></a>00322         {
<a name="l00323"></a>00323             <span class="keywordflow">for</span> (std::size_t i = 1; i &lt; myPoints.size(); ++i)
<a name="l00324"></a>00324             {
<a name="l00325"></a>00325                 <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a> PointColor = myPoints[i].OutlineCol * <a class="code" href="classsf_1_1Drawable.htm#a2a028c4a975b5ed6d5a560a1c44e0c8" title="Get the color of the object.">GetColor</a>();
<a name="l00326"></a>00326                 glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00327"></a>00327                 glVertex2f(myPoints[i].Position.x, myPoints[i].Position.y);
<a name="l00328"></a>00328                 glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00329"></a>00329                 glVertex2f(myPoints[i].Position.x + myPoints[i].Normal.x * myOutline, myPoints[i].Position.y + myPoints[i].Normal.y * myOutline);
<a name="l00330"></a>00330             }
<a name="l00331"></a>00331 
<a name="l00332"></a>00332             <span class="comment">// Close the shape by duplicating the first point at the end</span>
<a name="l00333"></a>00333             <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a> PointColor = myPoints[1].OutlineCol * <a class="code" href="classsf_1_1Drawable.htm#a2a028c4a975b5ed6d5a560a1c44e0c8" title="Get the color of the object.">GetColor</a>();
<a name="l00334"></a>00334             glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00335"></a>00335             glVertex2f(myPoints[1].Position.x, myPoints[1].Position.y);
<a name="l00336"></a>00336             glColor4f(PointColor.<a class="code" href="classsf_1_1Color.htm#6a5256ca24a4f9f0e0808f6fc23e01e1" title="Red component.">r</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#591daf9c3c55dea830c76c962d6ba1a5" title="Green component.">g</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#6707aedd0609c8920e12df5d7abc53cb" title="Blue component.">b</a> / 255.f, PointColor.<a class="code" href="classsf_1_1Color.htm#56dbdb47d5f040d9b78ac6a0b8b3a831" title="Alpha (transparency) component.">a</a> / 255.f);
<a name="l00337"></a>00337             glVertex2f(myPoints[1].Position.x + myPoints[1].Normal.x * myOutline, myPoints[1].Position.y + myPoints[1].Normal.y * myOutline);
<a name="l00338"></a>00338         }
<a name="l00339"></a>00339         glEnd();
<a name="l00340"></a>00340     }
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 
<a name="l00343"></a>00343 
<a name="l00347"></a>00347 <span class="keywordtype">void</span> Shape::Compile()
<a name="l00348"></a>00348 {
<a name="l00349"></a>00349     <span class="comment">// Compute the center</span>
<a name="l00350"></a>00350     <span class="keywordtype">float</span> NbPoints = <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(myPoints.size() - 1);
<a name="l00351"></a>00351     <span class="keywordtype">float</span> R = 0, G = 0, B = 0, A = 0;
<a name="l00352"></a>00352     Point Center(<a class="code" href="classsf_1_1Vector2.htm">Vector2f</a>(0, 0), <a class="code" href="classsf_1_1Color.htm" title="Color is an utility class for manipulating 32-bits RGBA colors.">Color</a>(0, 0, 0, 0));
<a name="l00353"></a>00353     <span class="keywordflow">for</span> (std::size_t i = 1; i &lt; myPoints.size(); ++i)
<a name="l00354"></a>00354     {
<a name="l00355"></a>00355         Center.Position += myPoints[i].Position / NbPoints;
<a name="l00356"></a>00356         R += myPoints[i].Col.r / NbPoints;
<a name="l00357"></a>00357         G += myPoints[i].Col.g / NbPoints;
<a name="l00358"></a>00358         B += myPoints[i].Col.b / NbPoints;
<a name="l00359"></a>00359         A += myPoints[i].Col.a / NbPoints;
<a name="l00360"></a>00360     }
<a name="l00361"></a>00361     Center.Col.r = <span class="keyword">static_cast&lt;</span>Uint8<span class="keyword">&gt;</span>(R);
<a name="l00362"></a>00362     Center.Col.g = <span class="keyword">static_cast&lt;</span>Uint8<span class="keyword">&gt;</span>(G);
<a name="l00363"></a>00363     Center.Col.b = <span class="keyword">static_cast&lt;</span>Uint8<span class="keyword">&gt;</span>(B);
<a name="l00364"></a>00364     Center.Col.a = <span class="keyword">static_cast&lt;</span>Uint8<span class="keyword">&gt;</span>(A);
<a name="l00365"></a>00365     myPoints[0] = Center;
<a name="l00366"></a>00366 
<a name="l00367"></a>00367     <span class="comment">// Compute the outline</span>
<a name="l00368"></a>00368     <span class="keywordflow">for</span> (std::size_t i = 1; i &lt; myPoints.size(); ++i)
<a name="l00369"></a>00369     {
<a name="l00370"></a>00370         <span class="comment">// Get the two segments shared by the current point</span>
<a name="l00371"></a>00371         Point&amp; P0 = (i == 1) ? myPoints[myPoints.size() - 1] : myPoints[i - 1];
<a name="l00372"></a>00372         Point&amp; P1 = myPoints[i];
<a name="l00373"></a>00373         Point&amp; P2 = (i == myPoints.size() - 1) ? myPoints[1] : myPoints[i + 1];
<a name="l00374"></a>00374 
<a name="l00375"></a>00375         <span class="comment">// Compute their normal</span>
<a name="l00376"></a>00376         Vector2f Normal1, Normal2;
<a name="l00377"></a>00377         <span class="keywordflow">if</span> (!ComputeNormal(P0.Position, P1.Position, Normal1) || !ComputeNormal(P1.Position, P2.Position, Normal2))
<a name="l00378"></a>00378             <span class="keywordflow">continue</span>;
<a name="l00379"></a>00379 
<a name="l00380"></a>00380         <span class="comment">// Add them to get the extrusion direction</span>
<a name="l00381"></a>00381         <span class="keywordtype">float</span> Factor = 1.f + (Normal1.x * Normal2.x + Normal1.y * Normal2.y);
<a name="l00382"></a>00382         P1.Normal = (Normal1 + Normal2) / Factor;
<a name="l00383"></a>00383 
<a name="l00384"></a>00384         <span class="comment">// Make sure it points towards the outside of the shape</span>
<a name="l00385"></a>00385         <span class="keywordtype">float</span> Dot = (P1.Position.x - Center.Position.x) * P1.Normal.x + (P1.Position.y - Center.Position.y) * P1.Normal.y;
<a name="l00386"></a>00386         <span class="keywordflow">if</span> (Dot &lt; 0)
<a name="l00387"></a>00387             P1.Normal = -P1.Normal;
<a name="l00388"></a>00388     }
<a name="l00389"></a>00389 
<a name="l00390"></a>00390     myIsCompiled = <span class="keyword">true</span>;
<a name="l00391"></a>00391 }
<a name="l00392"></a>00392 
<a name="l00393"></a>00393 
<a name="l00397"></a>00397 <span class="keywordtype">bool</span> Shape::ComputeNormal(<span class="keyword">const</span> Vector2f&amp; P1, <span class="keyword">const</span> Vector2f&amp; P2, Vector2f&amp; Normal)
<a name="l00398"></a>00398 {
<a name="l00399"></a>00399     Normal.x = P1.y - P2.y;
<a name="l00400"></a>00400     Normal.y = P2.x - P1.x;
<a name="l00401"></a>00401 
<a name="l00402"></a>00402     <span class="keywordtype">float</span> Len = sqrt(Normal.x * Normal.x + Normal.y * Normal.y);
<a name="l00403"></a>00403     <span class="keywordflow">if</span> (Len == 0.f)
<a name="l00404"></a>00404         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00405"></a>00405 
<a name="l00406"></a>00406     Normal.x /= Len;
<a name="l00407"></a>00407     Normal.y /= Len;
<a name="l00408"></a>00408 
<a name="l00409"></a>00409     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 
<a name="l00412"></a>00412 
<a name="l00416"></a>00416 Shape::Point::Point(<span class="keyword">const</span> Vector2f&amp; Pos, <span class="keyword">const</span> Color&amp; C, <span class="keyword">const</span> Color&amp; OutlineC) :
<a name="l00417"></a>00417 Position  (Pos),
<a name="l00418"></a>00418 Normal    (0.f, 0.f),
<a name="l00419"></a>00419 Col       (C),
<a name="l00420"></a>00420 OutlineCol(OutlineC)
<a name="l00421"></a>00421 {
<a name="l00422"></a>00422 
<a name="l00423"></a>00423 }
<a name="l00424"></a>00424 
<a name="l00425"></a>00425 } <span class="comment">// namespace sf</span>
</pre></div></div>

        <p id="footer">
            &nbsp;::&nbsp; Copyright &copy; 2007-2008 Laurent Gomila, all rights reserved &nbsp;::&nbsp;
            Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> &nbsp;::&nbsp;
        </p>

    </body>
</html>