4 Drawing primitives implements algorithms to draw basic geometric shapes such
5 as lines, circles, etc.
7 You may want to see the link:coordinate_system.html[coordinate system] first.
9 See also RGB tripplet to pixel link:convert.html[conversions].
14 Drawing orientation is affected by the link:pixmap.html[pixmap rotation
15 flags]. The parameters passed to the functions are transformed accordingly to
16 the flags before the drawing, which allows for fast and transparent rotated or
23 link:get_put_pixel.html[GetPixel and PutPixel] are implemented in the library
30 --------------------------------------------------------------------------------
31 void GP_Fill(GP_Pixmap *pixmap, GP_Pixel pixel);
32 --------------------------------------------------------------------------------
34 Fills the whole pixmap bitmap with the specified pixel value.
36 NOTE: GP_Fill is implemented in the library Core rather than in GFX so that
37 it's available to all library parts.
43 --------------------------------------------------------------------------------
44 void GP_HLineXXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y,
47 void GP_HLine(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y,
49 --------------------------------------------------------------------------------
51 Draws a horizontal line from (x0, y) to (x1, y), inclusive. The coordinates
52 x0, x1 can be specified in any order.
54 'GP_HLine()' is an alias for 'GP_HLineXXY()'.
57 --------------------------------------------------------------------------------
58 void GP_HLineXYW(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w,
60 --------------------------------------------------------------------------------
62 Draws a horizontal line from (x, y) to (x+w-1, y), inclusive.
66 --------------------------------------------------------------------------------
67 void GP_VLineXYY(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1,
70 void GP_VLine(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1,
72 --------------------------------------------------------------------------------
74 Draws a vertical line from (x, y0) to (x, y1), inclusive. The coordinates
75 y0, y1 can be specified in any order.
77 'GP_VLine()' is an alias for 'GP_VLineXYY()'.
80 --------------------------------------------------------------------------------
81 void GP_VLineXYH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h,
84 --------------------------------------------------------------------------------
86 Draws a vertical line from (x, y) to (x, y+h-1), inclusive.
89 --------------------------------------------------------------------------------
90 void GP_Line(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
91 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
92 --------------------------------------------------------------------------------
94 Draws a line from (x0, y0) to (x1, y1), inclusive. The starting and ending
95 point can be specified in any order (the implementation guarantees that
96 exactly the same set of pixels will be drawn in both cases).
102 --------------------------------------------------------------------------------
103 void GP_Circle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
104 GP_Size r, GP_Pixel pixel);
105 --------------------------------------------------------------------------------
107 Draws a circle centered at (xcenter, ycenter) with radius 'r' (in pixels).
109 The circle is drawn so that all affected pixels will fit into a square
110 specified by points (xcenter-r, ycenter-r, xcenter+r, ycenter+r), inclusive.
113 --------------------------------------------------------------------------------
114 void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
115 GP_Size r, GP_Pixel pixel);
116 --------------------------------------------------------------------------------
118 Draws a filled circle.
120 The set of pixels affected by 'GP_FillCircle()' is exactly the same as if
121 drawing the circle boundary using 'GP_Circle()' and then filling all pixels
122 within the boundary with the same color.
127 --------------------------------------------------------------------------------
128 void GP_Ring(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
129 GP_Size r1, GP_Size r2, GP_Pixel pixel);
130 --------------------------------------------------------------------------------
132 Draws a ring (two circles centered at (xcenter, ycenter) with radii 'r1' and 'r2').
134 The result is exactly the same as calling 'GP_Circle()' with the same center
135 and appropriate radii.
138 --------------------------------------------------------------------------------
139 void GP_FillRing(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
140 GP_Size r1, GP_Size r2, GP_Pixel pixel);
141 --------------------------------------------------------------------------------
145 The smaller of r1 and r2 is used for inner radius and bigger one for outer
152 --------------------------------------------------------------------------------
153 void GP_Ellipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
154 GP_Size a, GP_Size b, GP_Pixel pixel);
155 --------------------------------------------------------------------------------
157 Draws an axis-aligned ellipse.
159 The ellipse is drawn so that all affected pixels will fit into a rectangle
160 specified by points (xcenter-a, ycenter-b, xcenter+a, ycenter+b), inclusive.
163 --------------------------------------------------------------------------------
164 void GP_FillEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
165 GP_Size a, GP_Size b, GP_Pixel pixel);
166 --------------------------------------------------------------------------------
168 Draws a filled axis-aligned ellipse.
174 --------------------------------------------------------------------------------
175 void GP_Triangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
176 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
178 --------------------------------------------------------------------------------
183 --------------------------------------------------------------------------------
184 void GP_FillTriangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
185 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
187 --------------------------------------------------------------------------------
189 Draws a filled triangle.
195 --------------------------------------------------------------------------------
196 void GP_RectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
197 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
199 void GP_RectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
200 GP_Size w, GP_Size h, GP_Pixel pixel);
202 void GP_Rect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
203 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
204 --------------------------------------------------------------------------------
208 The 'GP_RectXYXY()' expects two corner points (x0, y0), and (x1, y1).
209 The 'GP_RectXYWH()' expects a corner point (x0, y0), width and height.
210 The 'GP_Rect()' function is an alias for 'GP_RectXYXY()'.
213 --------------------------------------------------------------------------------
214 void GP_FillRectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
215 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
217 void GP_FillRectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
218 GP_Size w, GP_Size h, GP_Pixel pixel);
220 void GP_FillRect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
221 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
222 --------------------------------------------------------------------------------
224 Draws a filled rectangle.
226 The 'GP_RectXYXY' fills an area between corner points (x0, y0) and (x1, y1),
228 The 'GP_RectXYWH' fills an area starting from (x0, y0) with specified width
229 and height, i.e. from (x0, y0) to (x0 + w, x1 + y), NOT inclusive.
230 The 'GP_FillRect()' functions is an alias for 'GP_FillRectXYXY()'.
236 --------------------------------------------------------------------------------
237 void GP_Tetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
238 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
239 GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
240 --------------------------------------------------------------------------------
245 --------------------------------------------------------------------------------
246 void GP_FillTetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
247 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
248 GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
249 --------------------------------------------------------------------------------
251 Draws a filled tetragon.
257 --------------------------------------------------------------------------------
258 void GP_Polygon(GP_Pixmap *pixmap, unsigned int vertex_count,
259 const GP_Coord *xy, GP_Pixel pixel);
260 --------------------------------------------------------------------------------
265 --------------------------------------------------------------------------------
266 void GP_FillPolygon(GP_Pixmap *pixmap, unsigned int vertex_count,
267 const GP_Coord *xy, GP_Pixel pixel);
268 --------------------------------------------------------------------------------
270 Draws a filled polygon.
272 The coordinages are passed in [x0, y0, x1, y1, ...] order, the vertex count
273 describes a number of nodes, i.e. half of the size of the array.