.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pods::SDL::GFX::Primitives 3pm" .TH pods::SDL::GFX::Primitives 3pm "2020-11-09" "perl v5.32.0" "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" \&\s-1GFX\s0 .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 \*(L"\s-1AUTHORS\*(R"\s0 in \s-1SDL\s0.