3 <h3 id="TOP">Index</h3>
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>
40 <li><a href="#AUTHORS">AUTHORS</a>
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>
50 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
51 <div id="CATEGORY_CONTENT">
55 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
56 <div id="DESCRIPTION_CONTENT">
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
58 obtained by <a href="/SDL-Video.html#set_video_mode">SDL::Video::set_video_mode</a> or can be an <a href="SDL-App.html">SDL::App</a>.</p>
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>
62 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63 <div id="METHODS_CONTENT">
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 );
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>
76 use SDL::GFX::Primitives;
78 my $surface = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
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
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 );
92 <p>Draws a line horizontally from <code>$x1</code>/<code>$y</code> to <code>$x2</code>/<code>$y</code>.</p>
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 );
101 <p>Draws a line vertically from <code>$x</code>/<code>$y1</code> to <code>$x</code>/<code>$y2</code>.</p>
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 );
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>
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 );
119 <p>Draws a filled rectangle.</p>
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 );
128 <p>Draws a free line from <code>$x1</code>/<code>$y1</code> to <code>$x2</code>/<code>$y</code>.</p>
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 );
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>
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 );
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 );
154 <p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
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 );
163 <p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
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 );
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 );
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 );
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 );
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 );
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>
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 );
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 );
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 );
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 );
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 );
246 <pre> SDL::GFX::Primitives::polygon_color($display, [262, 266, 264, 266, 262], [243, 243, 245, 247, 247], 5, 0xFF0000FF);
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 );
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 );
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 );
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 );
280 <p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
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 );
288 <p><strong>Note</strong>: You need lib SDL_gfx 2.0.17 or greater for this function.</p>
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 );
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>
299 <pre> SDL::GFX::Primitives::bezier_color($display, [390, 392, 394, 396], [243, 255, 235, 247], 4, 20, 0xFF00FFFF);
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 );
310 <p><code>$c</code> is the character that will be drawn at <code>$x</code>,<code>$y</code>.</p>
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 );
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 );
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>
329 open(FH, '<', 'data/5x7.fnt');
331 read(FH, $font, 4096);
334 SDL::GFX::Primitives::set_font($font, 5, 7);
339 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
340 <div id="AUTHORS_CONTENT">
341 <p>Tobias Leich [FROGGS]