pods::...itives(3pm)
β¨ NAME β¨
SDL::GFX::Primitives β basic drawing functions. This is the pods::...itives(3pm) page from the User Contributed Perl Documentation, bestie. π
π¦ CATEGORY π¦
GFX β that's the category, periodt.
πΈ DESCRIPTION πΈ
Okay so every single function here takes an SDL::Surface object as its first parameter. That can be a brand-new surface that gets blitted afterwards, or a surface you got from SDL::Video::set_video_mode, or it can be an SDLx::App. All valid, no cap. π
For the _color functions, the "color" values are "0xRRGGBBAA" (32bit) β yes, even if the surface uses e.g. 8bit colors. The format stays iconic. β¨
π METHODS π
Here's the whole roster, bestie β some have a little description, some are just signatures, and I'm keeping every single one either way. π«Ά
π pixel π
int SDL::GFX::Primitives::pixel_color( $surface, $x, $y, $color );
int SDL::GFX::Primitives::pixel_RGBA( $surface, $x, $y, $r, $g, $b, $a );
Draws a pixel at point x/$y. You can pass the color by 0xRRGGBBAA or by passing 4 values. One for red, green, blue and alpha.
Example:
use SDL;
use SDL::Video;
use SDL::Surface;
use SDL::GFX::Primitives;
my $surface = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
SDL::GFX::Primitives::pixel_color($surface, 2, 2, 0xFF0000FF); # red pixel
SDL::GFX::Primitives::pixel_RGBA( $surface, 4, 4, 0x00, 0xFF, 0x00, 0xFF); # green pixel
π hline π
int SDL::GFX::Primitives::hline_color( $surface, $x1, $x2, $y, $color );
int SDL::GFX::Primitives::hline_RGBA( $surface, $x1, $x2, $y, $r, $g, $b, $a );
Draws a line horizontally from $x1/$y to $x2/$y.
π vline π
int SDL::GFX::Primitives::vline_color( $surface, $x, $y1, $y2, $color );
int SDL::GFX::Primitives::vline_RGBA( $surface, $x, $y1, $y2, $r, $g, $b, $a );
Draws a line vertically from $x/$y1 to $x/$y2.
π rectangle π
int SDL::GFX::Primitives::rectangle_color( $surface, $x1, $y1, $x2, $y2, $color );
int SDL::GFX::Primitives::rectangle_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
Draws a rectangle. Upper left edge will be at $x1/$y1 and lower right at $x2/$y. The colored border has a width of 1 pixel.
π box π
int SDL::GFX::Primitives::box_color( $surface, $x1, $y1, $x2, $y2, $color );
int SDL::GFX::Primitives::box_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
Draws a filled rectangle.
π line π
int SDL::GFX::Primitives::line_color( $surface, $x1, $y1, $x2, $y2, $color );
int SDL::GFX::Primitives::line_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
Draws a free line from $x1/$y1 to $x2/$y.
π aaline π
int SDL::GFX::Primitives::aaline_color( $surface, $x1, $y1, $x2, $y2, $color );
int SDL::GFX::Primitives::aaline_RGBA( $surface, $x1, $y1, $x2, $y2, $r, $g, $b, $a );
Draws a free line from $x1/$y1 to $x2/$y. This line is anti aliased.
π circle π
int SDL::GFX::Primitives::circle_color( $surface, $x, $y, $r, $color );
int SDL::GFX::Primitives::circle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
π arc π
int SDL::GFX::Primitives::arc_color( $surface, $x, $y, $r, $start, $end, $color );
int SDL::GFX::Primitives::arc_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
Note: You need lib SDL_gfx 2.0.17 or greater for this function.
π aacircle π
int SDL::GFX::Primitives::aacircle_color( $surface, $x, $y, $r, $color );
int SDL::GFX::Primitives::aacircle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
Note: You need lib SDL_gfx 2.0.17 or greater for this function.
π filled_circle π
int SDL::GFX::Primitives::filled_circle_color( $surface, $x, $y, $r, $color );
int SDL::GFX::Primitives::filled_circle_RGBA( $surface, $x, $y, $rad, $r, $g, $b, $a );
π ellipse π
int SDL::GFX::Primitives::ellipse_color( $surface, $x, $y, $rx, $ry, $color );
int SDL::GFX::Primitives::ellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
π aaellipse π
int SDL::GFX::Primitives::aaellipse_color( $surface, $xc, $yc, $rx, $ry, $color );
int SDL::GFX::Primitives::aaellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
π filled_ellipse π
int SDL::GFX::Primitives::filled_ellipse_color( $surface, $x, $y, $rx, $ry, $color );
int SDL::GFX::Primitives::filled_ellipse_RGBA( $surface, $x, $y, $rx, $ry, $r, $g, $b, $a );
π pie π
int SDL::GFX::Primitives::pie_color( $surface, $x, $y, $rad, $start, $end, $color );
int SDL::GFX::Primitives::pie_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
This draws an opened pie. $start and $end are degree values. 0 is at right, 90 at bottom, 180 at left and 270 degrees at top.
π filled_pie π
int SDL::GFX::Primitives::filled_pie_color( $surface, $x, $y, $rad, $start, $end, $color );
int SDL::GFX::Primitives::filled_pie_RGBA( $surface, $x, $y, $rad, $start, $end, $r, $g, $b, $a );
π trigon π
int SDL::GFX::Primitives::trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
int SDL::GFX::Primitives::trigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
π aatrigon π
int SDL::GFX::Primitives::aatrigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
int SDL::GFX::Primitives::aatrigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
π filled_trigon π
int SDL::GFX::Primitives::filled_trigon_color( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $color );
int SDL::GFX::Primitives::filled_trigon_RGBA( $surface, $x1, $y1, $x2, $y2, $x3, $y3, $r, $g, $b, $a );
π polygon π
int SDL::GFX::Primitives::polygon_color( $surface, $vx, $vy, $n, $color );
int SDL::GFX::Primitives::polygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
Example:
SDL::GFX::Primitives::polygon_color($display, [262, 266, 264, 266, 262], [243, 243, 245, 247, 247], 5, 0xFF0000FF);
π aapolygon π
int SDL::GFX::Primitives::aapolygon_color( $surface, $vx, $vy, $n, $color );
int SDL::GFX::Primitives::aapolygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
π filled_polygon π
int SDL::GFX::Primitives::filled_polygon_color( $surface, $vx, $vy, $n, $color );
int SDL::GFX::Primitives::filled_polygon_RGBA( $surface, $vx, $vy, $n, $r, $g, $b, $a );
π textured_polygon π
int SDL::GFX::Primitives::textured_polygon( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy );
π filled_polygon_MT π
int SDL::GFX::Primitives::filled_polygon_color_MT( $surface, $vx, $vy, $n, $color, $polyInts, $polyAllocated );
int SDL::GFX::Primitives::filled_polygon_RGBA_MT( $surface, $vx, $vy, $n, $r, $g, $b, $a, $polyInts, $polyAllocated );
Note: You need lib SDL_gfx 2.0.17 or greater for this function.
π textured_polygon_MT π
int SDL::GFX::Primitives::textured_polygon_MT( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy, $polyInts, $polyAllocated );
Note: You need lib SDL_gfx 2.0.17 or greater for this function.
π bezier π
int SDL::GFX::Primitives::bezier_color( $surface, $vx, $vy, $n, $s, $color );
int SDL::GFX::Primitives::bezier_RGBA( $surface, $vx, $vy, $n, $s, $r, $g, $b, $a );
$n is the number of elements in $vx and $vy, and $s is the number of steps. So the bigger $s is, the smother it becomes.
Example:
SDL::GFX::Primitives::bezier_color($display, [390, 392, 394, 396], [243, 255, 235, 247], 4, 20, 0xFF00FFFF);
π character π
int SDL::GFX::Primitives::character_color( $surface, $x, $y, $c, $color );
int SDL::GFX::Primitives::character_RGBA( $surface, $x, $y, $c, $r, $g, $b, $a );
$c is the character that will be drawn at $x,$y.
π string π
int SDL::GFX::Primitives::string_color( $surface, $x, $y, $c, $color );
int SDL::GFX::Primitives::string_RGBA( $surface, $x, $y, $c, $r, $g, $b, $a );
π set_font π
void SDL::GFX::Primitives::set_font(fontdata, $cw, $ch );
The fontsets are included in the SDL_gfx distribution. Check http://www.ferzkopp.net/joomla/content/view/19/14/ for more.
Example:
my $font = '';
open(FH, '<', 'data/5x7.fnt');
binmode(FH);
read(FH, $font, 4096);
close(FH);
SDL::GFX::Primitives::set_font($font, 5, 7);
π AUTHORS π
See AUTHORS in SDL.
Later, bestie β this pods::...itives(3pm) page is from perl v5.42.3, dated 2026-08-19. ππ¦
π¦ where this page comes from
- ubuntu stonking: libsdl-perl 2.548-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms