.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "pods::SDL::GFX::Primitives 3pm" .TH pods::SDL::GFX::Primitives 3pm 2024-03-28 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SDL::GFX::Primitives \- basic drawing functions .SH CATEGORY .IX Header "CATEGORY" GFX .SH DESCRIPTION .IX Header "DESCRIPTION" All functions take an SDL::Surface object as first parameter. This can be a new surface that will be blitted afterwards, can be an surface obtained by SDL::Video::set_video_mode or can be an SDLx::App. .PP The \f(CW\*(C`color\*(C'\fR values for the \f(CW\*(C`_color\*(C'\fR functions are \f(CW\*(C`0xRRGGBBAA\*(C'\fR (32bit), even if the surface uses e. g. 8bit colors. .SH METHODS .IX Header "METHODS" .SS pixel .IX Subsection "pixel" .Vb 2 \& int SDL::GFX::Primitives::pixel_color( $surface, $x, $y, $color ); \& int SDL::GFX::Primitives::pixel_RGBA( $surface, $x, $y, $r, $g, $b, $a ); .Ve .PP Draws a pixel at point \f(CW\*(C`x\*(C'\fR/\f(CW$y\fR. You can pass the color by \f(CW\*(C`0xRRGGBBAA\*(C'\fR or by passing 4 values. One for red, green, blue and alpha. .PP .Vb 4 \& 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 .Ve .SS hline .IX Subsection "hline" .Vb 2 \& 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 ); .Ve .PP Draws a line horizontally from \f(CW$x1\fR/\f(CW$y\fR to \f(CW$x2\fR/\f(CW$y\fR. .SS vline .IX Subsection "vline" .Vb 2 \& 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 ); .Ve .PP Draws a line vertically from \f(CW$x\fR/\f(CW$y1\fR to \f(CW$x\fR/\f(CW$y2\fR. .SS rectangle .IX Subsection "rectangle" .Vb 2 \& 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 ); .Ve .PP Draws a rectangle. Upper left edge will be at \f(CW$x1\fR/\f(CW$y1\fR and lower right at \f(CW$x2\fR/\f(CW$y\fR. The colored border has a width of 1 pixel. .SS box .IX Subsection "box" .Vb 2 \& 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 ); .Ve .PP Draws a filled rectangle. .SS line .IX Subsection "line" .Vb 2 \& 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 ); .Ve .PP Draws a free line from \f(CW$x1\fR/\f(CW$y1\fR to \f(CW$x2\fR/\f(CW$y\fR. .SS aaline .IX Subsection "aaline" .Vb 2 \& 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 ); .Ve .PP Draws a free line from \f(CW$x1\fR/\f(CW$y1\fR to \f(CW$x2\fR/\f(CW$y\fR. This line is anti aliased. .SS circle .IX Subsection "circle" .Vb 2 \& 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 ); .Ve .SS arc .IX Subsection "arc" .Vb 2 \& 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 ); .Ve .PP \&\fBNote\fR: You need lib SDL_gfx 2.0.17 or greater for this function. .SS aacircle .IX Subsection "aacircle" .Vb 2 \& 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 ); .Ve .PP \&\fBNote\fR: You need lib SDL_gfx 2.0.17 or greater for this function. .SS filled_circle .IX Subsection "filled_circle" .Vb 2 \& 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 ); .Ve .SS ellipse .IX Subsection "ellipse" .Vb 2 \& 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 ); .Ve .SS aaellipse .IX Subsection "aaellipse" .Vb 2 \& 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 ); .Ve .SS filled_ellipse .IX Subsection "filled_ellipse" .Vb 2 \& 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 ); .Ve .SS pie .IX Subsection "pie" .Vb 2 \& 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 ); .Ve .PP This draws an opened pie. \f(CW$start\fR and \f(CW$end\fR are degree values. \f(CW0\fR is at right, \f(CW90\fR at bottom, \f(CW180\fR at left and \f(CW270\fR degrees at top. .SS filled_pie .IX Subsection "filled_pie" .Vb 2 \& 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 ); .Ve .SS trigon .IX Subsection "trigon" .Vb 2 \& 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 ); .Ve .SS aatrigon .IX Subsection "aatrigon" .Vb 2 \& 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 ); .Ve .SS filled_trigon .IX Subsection "filled_trigon" .Vb 2 \& 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 ); .Ve .SS polygon .IX Subsection "polygon" .Vb 2 \& 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 ); .Ve .PP Example: .PP .Vb 1 \& SDL::GFX::Primitives::polygon_color($display, [262, 266, 264, 266, 262], [243, 243, 245, 247, 247], 5, 0xFF0000FF); .Ve .SS aapolygon .IX Subsection "aapolygon" .Vb 2 \& 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 ); .Ve .SS filled_polygon .IX Subsection "filled_polygon" .Vb 2 \& 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 ); .Ve .SS textured_polygon .IX Subsection "textured_polygon" .Vb 1 \& int SDL::GFX::Primitives::textured_polygon( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy ); .Ve .SS filled_polygon_MT .IX Subsection "filled_polygon_MT" .Vb 2 \& 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 ); .Ve .PP \&\fBNote\fR: You need lib SDL_gfx 2.0.17 or greater for this function. .SS textured_polygon_MT .IX Subsection "textured_polygon_MT" .Vb 1 \& int SDL::GFX::Primitives::textured_polygon_MT( $surface, $vx, $vy, $n, $texture, $texture_dx, $texture_dy, $polyInts, $polyAllocated ); .Ve .PP \&\fBNote\fR: You need lib SDL_gfx 2.0.17 or greater for this function. .SS bezier .IX Subsection "bezier" .Vb 2 \& 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 ); .Ve .PP \&\f(CW$n\fR is the number of elements in \f(CW$vx\fR and \f(CW$vy\fR, and \f(CW$s\fR is the number of steps. So the bigger \f(CW$s\fR is, the smother it becomes. .PP Example: .PP .Vb 1 \& SDL::GFX::Primitives::bezier_color($display, [390, 392, 394, 396], [243, 255, 235, 247], 4, 20, 0xFF00FFFF); .Ve .SS character .IX Subsection "character" .Vb 2 \& 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 ); .Ve .PP \&\f(CW$c\fR is the character that will be drawn at \f(CW$x\fR,\f(CW$y\fR. .SS string .IX Subsection "string" .Vb 2 \& 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 ); .Ve .SS set_font .IX Subsection "set_font" .Vb 1 \& void SDL::GFX::Primitives::set_font(fontdata, $cw, $ch ); .Ve .PP The fontsets are included in the SDL_gfx distribution. Check for more. .PP Example: .PP .Vb 5 \& my $font = \*(Aq\*(Aq; \& open(FH, \*(Aq<\*(Aq, \*(Aqdata/5x7.fnt\*(Aq); \& binmode(FH); \& read(FH, $font, 4096); \& close(FH); \& \& SDL::GFX::Primitives::set_font($font, 5, 7); .Ve .SH AUTHORS .IX Header "AUTHORS" See "AUTHORS" in SDL.