PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/pods/SDL/GFX/Primitives.pod

http://github.com/PerlGameDev/SDL
Unknown | 222 lines | 128 code | 94 blank | 0 comment | 0 complexity | 944048531983b635169d9a73ff1239c6 MD5 | raw file
  1
  2=head1 NAME
  3
  4SDL::GFX::Primitives - basic drawing functions
  5
  6=head1 CATEGORY
  7
  8GFX
  9
 10=head1	DESCRIPTION
 11
 12All functions take an SDL::Surface object as first parameter. This can be a new surface that will be blitted afterwards, can be an surface 
 13obtained by L<SDL::Video::set_video_mode|SDL::Video/"set_video_mode"> or can be an L<SDLx::App>.
 14
 15The C<color> values for the C<_color> functions are C<0xRRGGBBAA> (32bit), even if the surface uses e. g. 8bit colors.
 16
 17=head1	METHODS
 18
 19=head2	pixel
 20
 21 int SDL::GFX::Primitives::pixel_color( $surface, $x, $y, $color );
 22 int SDL::GFX::Primitives::pixel_RGBA(  $surface, $x, $y, $r, $g, $b, $a );
 23
 24Draws a pixel at point C<x>/C<$y>. You can pass the color by C<0xRRGGBBAA> or by passing 4 values. One for red, green, blue and alpha.
 25
 26 use SDL;
 27 use SDL::Video;
 28 use SDL::Surface;
 29 use SDL::GFX::Primitives;
 30
 31 my $surface = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
 32 
 33 SDL::GFX::Primitives::pixel_color($surface, 2, 2, 0xFF0000FF);             # red pixel
 34 SDL::GFX::Primitives::pixel_RGBA( $surface, 4, 4, 0x00, 0xFF, 0x00, 0xFF); # green pixel
 35
 36=head2	hline
 37
 38 int SDL::GFX::Primitives::hline_color( $surface, $x1, $x2, $y, $color );
 39 int SDL::GFX::Primitives::hline_RGBA(  $surface, $x1, $x2, $y, $r, $g, $b, $a );
 40
 41Draws a line horizontally from C<$x1>/C<$y> to C<$x2>/C<$y>.
 42
 43=head2	vline
 44
 45 int SDL::GFX::Primitives::vline_color( $surface, $x, $y1, $y2, $color );
 46 int SDL::GFX::Primitives::vline_RGBA(  $surface, $x, $y1, $y2, $r, $g, $b, $a );
 47
 48Draws a line vertically from C<$x>/C<$y1> to C<$x>/C<$y2>.
 49
 50=head2	rectangle
 51
 52 int SDL::GFX::Primitives::rectangle_color( $surface, $x1, $y1, $x2, $y2, $color );
 53 int SDL::GFX::Primitives::rectangle_RGBA(  $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
 54
 55Draws a rectangle. Upper left edge will be at C<$x1>/C<$y1> and lower right at C<$x2>/C<$y>. The colored border has a width of 1 pixel.
 56
 57=head2	box
 58
 59 int SDL::GFX::Primitives::box_color( $surface, $x1, $y1, $x2, $y2, $color );
 60 int SDL::GFX::Primitives::box_RGBA(  $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
 61
 62Draws a filled rectangle.
 63
 64=head2	line
 65
 66 int SDL::GFX::Primitives::line_color( $surface, $x1, $y1, $x2, $y2, $color );
 67 int SDL::GFX::Primitives::line_RGBA(  $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
 68
 69Draws a free line from C<$x1>/C<$y1> to C<$x2>/C<$y>.
 70
 71=head2	aaline
 72
 73 int SDL::GFX::Primitives::aaline_color( $surface, $x1, $y1, $x2, $y2, $color );
 74 int SDL::GFX::Primitives::aaline_RGBA(  $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
 75
 76Draws a free line from C<$x1>/C<$y1> to C<$x2>/C<$y>. This line is anti aliased.
 77
 78=head2	circle
 79
 80 int SDL::GFX::Primitives::circle_color( $surface, $x, $y, $r, $color );
 81 int SDL::GFX::Primitives::circle_RGBA(  $surface, $x, $y, $rad, $r, $g, $b, $a );
 82
 83=head2	arc
 84
 85 int SDL::GFX::Primitives::arc_color( $surface, $x, $y, $r, $start, $end, $color );
 86 int SDL::GFX::Primitives::arc_RGBA(  $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
 87
 88B<Note>: You need lib SDL_gfx 2.0.17 or greater for this function.
 89
 90=head2	aacircle
 91
 92 int SDL::GFX::Primitives::aacircle_color( $surface, $x, $y, $r, $color );
 93 int SDL::GFX::Primitives::aacircle_RGBA(  $surface, $x, $y, $rad, $r, $g, $b, $a );
 94
 95B<Note>: You need lib SDL_gfx 2.0.17 or greater for this function.
 96
 97=head2	filled_circle
 98
 99 int SDL::GFX::Primitives::filled_circle_color( $surface, $x, $y, $r, $color );
100 int SDL::GFX::Primitives::filled_circle_RGBA(  $surface, $x, $y, $rad, $r, $g, $b, $a );
101
102=head2	ellipse
103
104 int SDL::GFX::Primitives::ellipse_color( $surface, $x, $y, $rx, $ry, $color );
105 int SDL::GFX::Primitives::ellipse_RGBA(  $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
106
107=head2	aaellipse
108
109 int SDL::GFX::Primitives::aaellipse_color( $surface, $xc, $yc, $rx, $ry, $color );
110 int SDL::GFX::Primitives::aaellipse_RGBA(  $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
111
112=head2	filled_ellipse
113
114 int SDL::GFX::Primitives::filled_ellipse_color( $surface, $x, $y, $rx, $ry, $color );
115 int SDL::GFX::Primitives::filled_ellipse_RGBA(  $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
116
117=head2	pie
118
119 int SDL::GFX::Primitives::pie_color( $surface, $x, $y, $rad, $start, $end, $color );
120 int SDL::GFX::Primitives::pie_RGBA(  $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
121
122This draws an opened pie. C<$start> and C<$end> are degree values. C<0> is at right, C<90> at bottom, C<180> at left and C<270> degrees at top.
123
124=head2	filled_pie
125
126 int SDL::GFX::Primitives::filled_pie_color( $surface, $x, $y, $rad, $start, $end, $color );
127 int SDL::GFX::Primitives::filled_pie_RGBA(  $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
128
129=head2	trigon
130
131 int SDL::GFX::Primitives::trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
132 int SDL::GFX::Primitives::trigon_RGBA(  $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
133
134=head2	aatrigon
135
136 int SDL::GFX::Primitives::aatrigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
137 int SDL::GFX::Primitives::aatrigon_RGBA(  $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
138
139=head2	filled_trigon
140
141 int SDL::GFX::Primitives::filled_trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
142 int SDL::GFX::Primitives::filled_trigon_RGBA(  $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
143
144=head2	polygon
145
146 int SDL::GFX::Primitives::polygon_color( $surface, $vx, $vy, $n, $color );
147 int SDL::GFX::Primitives::polygon_RGBA(  $surface, $vx, $vy, $n, $r, $g, $b, $a );
148
149Example:
150
151 SDL::GFX::Primitives::polygon_color($display, [262, 266, 264, 266, 262], [243, 243, 245, 247, 247], 5, 0xFF0000FF);
152
153=head2	aapolygon
154
155 int SDL::GFX::Primitives::aapolygon_color( $surface, $vx, $vy, $n, $color );
156 int SDL::GFX::Primitives::aapolygon_RGBA(  $surface, $vx, $vy, $n, $r, $g, $b, $a );
157
158=head2	filled_polygon
159
160 int SDL::GFX::Primitives::filled_polygon_color( $surface, $vx, $vy, $n, $color );
161 int SDL::GFX::Primitives::filled_polygon_RGBA(  $surface, $vx, $vy, $n, $r, $g, $b, $a );
162
163=head2	textured_polygon
164
165 int SDL::GFX::Primitives::textured_polygon( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy );
166
167=head2	filled_polygon_MT
168
169 int SDL::GFX::Primitives::filled_polygon_color_MT( $surface, $vx, $vy, $n, $color, $polyInts, $polyAllocated );
170 int SDL::GFX::Primitives::filled_polygon_RGBA_MT(  $surface, $vx, $vy, $n, $r, $g, $b, $a, $polyInts, $polyAllocated );
171
172B<Note>: You need lib SDL_gfx 2.0.17 or greater for this function.
173
174=head2	textured_polygon_MT
175
176 int SDL::GFX::Primitives::textured_polygon_MT( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy, $polyInts, $polyAllocated );
177
178B<Note>: You need lib SDL_gfx 2.0.17 or greater for this function.
179
180=head2	bezier
181
182 int SDL::GFX::Primitives::bezier_color( $surface, $vx, $vy, $n, $s, $color );
183 int SDL::GFX::Primitives::bezier_RGBA(  $surface, $vx, $vy, $n, $s, $r, $g, $b, $a );
184
185C<$n> is the number of elements in C<$vx> and C<$vy>, and C<$s> is the number of steps. So the bigger C<$s> is, the smother it becomes.
186
187Example:
188
189 SDL::GFX::Primitives::bezier_color($display, [390, 392, 394, 396], [243, 255, 235, 247], 4, 20, 0xFF00FFFF);
190
191=head2	character
192
193 int SDL::GFX::Primitives::character_color( $surface, $x, $y, $c, $color );
194 int SDL::GFX::Primitives::character_RGBA(  $surface, $x, $y, $c, $r, $g, $b, $a );
195
196C<$c> is the character that will be drawn at C<$x>,C<$y>.
197
198=head2	string
199
200 int SDL::GFX::Primitives::string_color( $surface, $x, $y, $c, $color );
201 int SDL::GFX::Primitives::string_RGBA(  $surface, $x, $y, $c, $r, $g, $b, $a );
202
203=head2	set_font
204
205 void SDL::GFX::Primitives::set_font(fontdata, $cw, $ch );
206
207The fontsets are included in the SDL_gfx distribution. Check L<http://www.ferzkopp.net/joomla/content/view/19/14/> for more.
208
209Example:
210
211 my $font = '';
212 open(FH, '<', 'data/5x7.fnt');
213 binmode(FH);
214 read(FH, $font, 4096);
215 close(FH);
216
217 SDL::GFX::Primitives::set_font($font, 5, 7);
218
219=head1 AUTHORS
220
221See L<SDL/AUTHORS>.
222