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