Merge branch 'master' of git.shadowcat.co.uk:SDL-Site
[sdlgit/SDL-Site.git] / pages / SDL-GFX-Primitives.html-inc
CommitLineData
cf23a5da 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
6<li><a href="#CATEGORY">CATEGORY</a></li>
7<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
8<li><a href="#METHODS">METHODS</a>
9<ul><li><a href="#pixel">pixel</a></li>
10<li><a href="#hline">hline</a></li>
11<li><a href="#vline">vline</a></li>
12<li><a href="#rectangle">rectangle</a></li>
13<li><a href="#box">box</a></li>
14<li><a href="#line">line</a></li>
15<li><a href="#aaline">aaline</a></li>
16<li><a href="#circle">circle</a></li>
17<li><a href="#arc">arc</a></li>
18<li><a href="#aacircle">aacircle</a></li>
19<li><a href="#filled_circle">filled_circle</a></li>
20<li><a href="#ellipse">ellipse</a></li>
21<li><a href="#aaellipse">aaellipse</a></li>
22<li><a href="#filled_ellipse">filled_ellipse</a></li>
23<li><a href="#pie">pie</a></li>
24<li><a href="#filled_pie">filled_pie</a></li>
25<li><a href="#trigon">trigon</a></li>
26<li><a href="#aatrigon">aatrigon</a></li>
27<li><a href="#filled_trigon">filled_trigon</a></li>
28<li><a href="#polygon">polygon</a></li>
29<li><a href="#aapolygon">aapolygon</a></li>
30<li><a href="#filled_polygon">filled_polygon</a></li>
31<li><a href="#textured_polygon">textured_polygon</a></li>
32<li><a href="#filled_polygon_MT">filled_polygon_MT</a></li>
33<li><a href="#textured_polygon_MT">textured_polygon_MT</a></li>
34<li><a href="#bezier">bezier</a></li>
35<li><a href="#character">character</a></li>
36<li><a href="#string">string</a></li>
37<li><a href="#set_font">set_font</a></li>
38</ul>
39</li>
40<li><a href="#AUTHORS">AUTHORS</a>
41</li>
42</ul><hr />
43<!-- INDEX END -->
44
45<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
46<div id="NAME_CONTENT">
47<p>SDL::GFX::Primitives - basic drawing functions</p>
48
49</div>
50<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
51<div id="CATEGORY_CONTENT">
b5d537cc 52<p>GFX</p>
cf23a5da 53
54</div>
55<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
56<div id="DESCRIPTION_CONTENT">
25fbbc5b 57<p>All functions take an SDL::Surface object as first parameter. This can be a new surface that will be blittet afterwads, can be an surface
1dbe1697 58obtained by <a href="/SDL-Video.html#set_video_mode">SDL::Video::set_video_mode</a> or can be an <a href="SDLx-App.html">SDLx::App</a>.</p>
25fbbc5b 59<p>The <code>color</code> values for the <code>_color</code> functions are <code>0xRRGGBBAA</code> (32bit), even if the surface uses e. g. 8bit colors.</p>
cf23a5da 60
61</div>
62<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63<div id="METHODS_CONTENT">
64
65</div>
66<h2 id="pixel">pixel</h2>
67<div id="pixel_CONTENT">
68<pre> int SDL::GFX::Primitives::pixel_color( $surface, $x, $y, $color );
69 int SDL::GFX::Primitives::pixel_RGBA( $surface, $x, $y, $r, $g, $b, $a );
70
71</pre>
72<p>Draws a pixel at point <code>x</code>/<code>$y</code>. You can pass the color by <code>0xRRGGBBAA</code> or by passing 4 values. One for red, green, blue and alpha.</p>
73<pre> use SDL;
74 use SDL::Video;
75 use SDL::Surface;
76 use SDL::GFX::Primitives;
77
25fbbc5b 78 my $surface = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
cf23a5da 79
25fbbc5b 80 SDL::GFX::Primitives::pixel_color($surface, 2, 2, 0xFF0000FF); # red pixcel
81 SDL::GFX::Primitives::pixel_RGBA( $surface, 4, 4, 0x00, 0xFF, 0x00, 0xFF); # green pixel
cf23a5da 82
83</pre>
84
85</div>
86<h2 id="hline">hline</h2>
87<div id="hline_CONTENT">
88<pre> int SDL::GFX::Primitives::hline_color( $surface, $x1, $x2, $y, $color );
89 int SDL::GFX::Primitives::hline_RGBA( $surface, $x1, $x2, $y, $r, $g, $b, $a );
90
91</pre>
92<p>Draws a line horizontally from <code>$x1</code>/<code>$y</code> to <code>$x2</code>/<code>$y</code>.</p>
93
94</div>
95<h2 id="vline">vline</h2>
96<div id="vline_CONTENT">
97<pre> int SDL::GFX::Primitives::vline_color( $surface, $x, $y1, $y2, $color );
98 int SDL::GFX::Primitives::vline_RGBA( $surface, $x, $y1, $y2, $r, $g, $b, $a );
99
100</pre>
101<p>Draws a line vertically from <code>$x</code>/<code>$y1</code> to <code>$x</code>/<code>$y2</code>.</p>
102
103</div>
104<h2 id="rectangle">rectangle</h2>
105<div id="rectangle_CONTENT">
106<pre> int SDL::GFX::Primitives::rectangle_color( $surface, $x1, $y1, $x2, $y2, $color );
107 int SDL::GFX::Primitives::rectangle_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
108
109</pre>
110<p>Draws a rectangle. Upper left edge will be at <code>$x1</code>/<code>$y1</code> and lower right at <code>$x2</code>/<code>$y</code>. The colored border has a width of 1 pixel.</p>
111
112</div>
113<h2 id="box">box</h2>
114<div id="box_CONTENT">
115<pre> int SDL::GFX::Primitives::box_color( $surface, $x1, $y1, $x2, $y2, $color );
116 int SDL::GFX::Primitives::box_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
117
118</pre>
119<p>Draws a filled rectangle.</p>
120
121</div>
122<h2 id="line">line</h2>
123<div id="line_CONTENT">
124<pre> int SDL::GFX::Primitives::line_color( $surface, $x1, $y1, $x2, $y2, $color );
125 int SDL::GFX::Primitives::line_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
126
127</pre>
128<p>Draws a free line from <code>$x1</code>/<code>$y1</code> to <code>$x2</code>/<code>$y</code>.</p>
129
130</div>
131<h2 id="aaline">aaline</h2>
132<div id="aaline_CONTENT">
133<pre> int SDL::GFX::Primitives::aaline_color( $surface, $x1, $y1, $x2, $y2, $color );
134 int SDL::GFX::Primitives::aaline_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
135
136</pre>
137<p>Draws a free line from <code>$x1</code>/<code>$y1</code> to <code>$x2</code>/<code>$y</code>. This line is anti aliased.</p>
138
139</div>
140<h2 id="circle">circle</h2>
141<div id="circle_CONTENT">
142<pre> int SDL::GFX::Primitives::circle_color( $surface, $x, $y, $r, $color );
143 int SDL::GFX::Primitives::circle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
144
145</pre>
146
147</div>
148<h2 id="arc">arc</h2>
149<div id="arc_CONTENT">
150<pre> int SDL::GFX::Primitives::arc_color( $surface, $x, $y, $r, $start, $end, $color );
151 int SDL::GFX::Primitives::arc_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
152
153</pre>
154<p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
155
156</div>
157<h2 id="aacircle">aacircle</h2>
158<div id="aacircle_CONTENT">
159<pre> int SDL::GFX::Primitives::aacircle_color( $surface, $x, $y, $r, $color );
160 int SDL::GFX::Primitives::aacircle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
161
162</pre>
163<p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
164
165</div>
166<h2 id="filled_circle">filled_circle</h2>
167<div id="filled_circle_CONTENT">
168<pre> int SDL::GFX::Primitives::filled_circle_color( $surface, $x, $y, $r, $color );
169 int SDL::GFX::Primitives::filled_circle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
170
171</pre>
172
173</div>
174<h2 id="ellipse">ellipse</h2>
175<div id="ellipse_CONTENT">
176<pre> int SDL::GFX::Primitives::ellipse_color( $surface, $x, $y, $rx, $ry, $color );
177 int SDL::GFX::Primitives::ellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
178
179</pre>
180
181</div>
182<h2 id="aaellipse">aaellipse</h2>
183<div id="aaellipse_CONTENT">
184<pre> int SDL::GFX::Primitives::aaellipse_color( $surface, $xc, $yc, $rx, $ry, $color );
185 int SDL::GFX::Primitives::aaellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
186
187</pre>
188
189</div>
190<h2 id="filled_ellipse">filled_ellipse</h2>
191<div id="filled_ellipse_CONTENT">
192<pre> int SDL::GFX::Primitives::filled_ellipse_color( $surface, $x, $y, $rx, $ry, $color );
193 int SDL::GFX::Primitives::filled_ellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
194
195</pre>
196
197</div>
198<h2 id="pie">pie</h2>
199<div id="pie_CONTENT">
200<pre> int SDL::GFX::Primitives::pie_color( $surface, $x, $y, $rad, $start, $end, $color );
201 int SDL::GFX::Primitives::pie_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
202
203</pre>
204<p>This draws an opened pie. <code>$start</code> and <code>$end</code> are degree values. <code>0</code> is at right, <code>90</code> at bottom, <code>180</code> at left and <code>270</code> degrees at top.</p>
205
206</div>
207<h2 id="filled_pie">filled_pie</h2>
208<div id="filled_pie_CONTENT">
209<pre> int SDL::GFX::Primitives::filled_pie_color( $surface, $x, $y, $rad, $start, $end, $color );
210 int SDL::GFX::Primitives::filled_pie_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
211
212</pre>
213
214</div>
215<h2 id="trigon">trigon</h2>
216<div id="trigon_CONTENT">
217<pre> int SDL::GFX::Primitives::trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
218 int SDL::GFX::Primitives::trigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
219
220</pre>
221
222</div>
223<h2 id="aatrigon">aatrigon</h2>
224<div id="aatrigon_CONTENT">
225<pre> int SDL::GFX::Primitives::aatrigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
226 int SDL::GFX::Primitives::aatrigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
227
228</pre>
229
230</div>
231<h2 id="filled_trigon">filled_trigon</h2>
232<div id="filled_trigon_CONTENT">
233<pre> int SDL::GFX::Primitives::filled_trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
234 int SDL::GFX::Primitives::filled_trigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
235
236</pre>
237
238</div>
239<h2 id="polygon">polygon</h2>
240<div id="polygon_CONTENT">
241<pre> int SDL::GFX::Primitives::polygon_color( $surface, $vx, $vy, $n, $color );
242 int SDL::GFX::Primitives::polygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
243
244</pre>
245<p>Example:</p>
246<pre> SDL::GFX::Primitives::polygon_color($display, [262, 266, 264, 266, 262], [243, 243, 245, 247, 247], 5, 0xFF0000FF);
247
248</pre>
249
250</div>
251<h2 id="aapolygon">aapolygon</h2>
252<div id="aapolygon_CONTENT">
253<pre> int SDL::GFX::Primitives::aapolygon_color( $surface, $vx, $vy, $n, $color );
254 int SDL::GFX::Primitives::aapolygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
255
256</pre>
257
258</div>
259<h2 id="filled_polygon">filled_polygon</h2>
260<div id="filled_polygon_CONTENT">
261<pre> int SDL::GFX::Primitives::filled_polygon_color( $surface, $vx, $vy, $n, $color );
262 int SDL::GFX::Primitives::filled_polygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
263
264</pre>
265
266</div>
267<h2 id="textured_polygon">textured_polygon</h2>
268<div id="textured_polygon_CONTENT">
269<pre> int SDL::GFX::Primitives::textured_polygon( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy );
270
271</pre>
272
273</div>
274<h2 id="filled_polygon_MT">filled_polygon_MT</h2>
275<div id="filled_polygon_MT_CONTENT">
276<pre> int SDL::GFX::Primitives::filled_polygon_color_MT( $surface, $vx, $vy, $n, $color, $polyInts, $polyAllocated );
277 int SDL::GFX::Primitives::filled_polygon_RGBA_MT( $surface, $vx, $vy, $n, $r, $g, $b, $a, $polyInts, $polyAllocated );
278
279</pre>
280<p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
281
282</div>
283<h2 id="textured_polygon_MT">textured_polygon_MT</h2>
284<div id="textured_polygon_MT_CONTENT">
285<pre> int SDL::GFX::Primitives::textured_polygon_MT( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy, $polyInts, $polyAllocated );
286
287</pre>
288<p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
289
290</div>
291<h2 id="bezier">bezier</h2>
292<div id="bezier_CONTENT">
293<pre> int SDL::GFX::Primitives::bezier_color( $surface, $vx, $vy, $n, $s, $color );
294 int SDL::GFX::Primitives::bezier_RGBA( $surface, $vx, $vy, $n, $s, $r, $g, $b, $a );
295
296</pre>
297<p><code>$n</code> is the number of elements in <code>$vx</code> and <code>$vy</code>, and <code>$s</code> is the number of steps. So the bigger <code>$s</code> is, the smother it becomes.</p>
298<p>Example:</p>
299<pre> SDL::GFX::Primitives::bezier_color($display, [390, 392, 394, 396], [243, 255, 235, 247], 4, 20, 0xFF00FFFF);
300
301</pre>
302
303</div>
304<h2 id="character">character</h2>
305<div id="character_CONTENT">
306<pre> int SDL::GFX::Primitives::character_color( $surface, $x, $y, $c, $color );
307 int SDL::GFX::Primitives::character_RGBA( $surface, $x, $y, $c, $r, $g, $b, $a );
308
309</pre>
310<p><code>$c</code> is the character that will be drawn at <code>$x</code>,<code>$y</code>.</p>
311
312</div>
313<h2 id="string">string</h2>
314<div id="string_CONTENT">
315<pre> int SDL::GFX::Primitives::string_color( $surface, $x, $y, $c, $color );
316 int SDL::GFX::Primitives::string_RGBA( $surface, $x, $y, $c, $r, $g, $b, $a );
317
318</pre>
319
320</div>
321<h2 id="set_font">set_font</h2>
322<div id="set_font_CONTENT">
323<pre> void SDL::GFX::Primitives::set_font(fontdata, $cw, $ch );
324
325</pre>
326<p>The fontsets are included in the SDL_gfx distribution. Check <a href="http://www.ferzkopp.net/joomla/content/view/19/14/">http://www.ferzkopp.net/joomla/content/view/19/14/</a> for more.</p>
327<p>Example:</p>
328<pre> my $font = '';
329 open(FH, '&lt;', 'data/5x7.fnt');
330 binmode(FH);
331 read(FH, $font, 4096);
332 close(FH);
333
334 SDL::GFX::Primitives::set_font($font, 5, 7);
335
336</pre>
337
338</div>
339<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
340<div id="AUTHORS_CONTENT">
1dbe1697 341<p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
cf23a5da 342
343</div>
344</div>