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.
12 Drawing orientation is affected by the link:context.html[context rotation
13 flags]. The parameters passed to the functions are transformed accordingly to
14 the flags before the drawing, which allows for fast and transparent rotated or
21 link:get_put_pixel.html[GetPixel and PutPixel] are implemented in the library
28 --------------------------------------------------------------------------------
29 void GP_Fill(GP_Context *context, GP_Pixel pixel);
30 --------------------------------------------------------------------------------
32 Fills the whole context bitmap with the specified pixel value.
34 NOTE: GP_Fill is implemented in the library Core rather than in GFX so that
35 it's available to all library parts.
41 --------------------------------------------------------------------------------
42 void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
45 void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
47 --------------------------------------------------------------------------------
49 Draws a horizontal line from (x0, y) to (x1, y), inclusive. The coordinates
50 x0, x1 can be specified in any order.
52 'GP_HLine()' is an alias for 'GP_HLineXXY()'.
55 --------------------------------------------------------------------------------
56 void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
58 --------------------------------------------------------------------------------
60 Draws a horizontal line from (x, y) to (x+w-1, y), inclusive.
64 --------------------------------------------------------------------------------
65 void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
68 void GP_VLine(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
70 --------------------------------------------------------------------------------
72 Draws a vertical line from (x, y0) to (x, y1), inclusive. The coordinates
73 y0, y1 can be specified in any order.
75 'GP_VLine()' is an alias for 'GP_VLineXYY()'.
78 --------------------------------------------------------------------------------
79 void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
82 --------------------------------------------------------------------------------
84 Draws a vertical line from (x, y) to (x, y+h-1), inclusive.
87 --------------------------------------------------------------------------------
88 void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
89 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
90 --------------------------------------------------------------------------------
92 Draws a line from (x0, y0) to (x1, y1), inclusive. The starting and ending
93 point can be specified in any order (the implementation guarantees that
94 exactly the same set of pixels will be drawn in both cases).
100 --------------------------------------------------------------------------------
101 void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
102 GP_Size r, GP_Pixel pixel);
103 --------------------------------------------------------------------------------
105 Draws a circle centered at (xcenter, ycenter) with radius 'r' (in pixels).
107 The circle is drawn so that all affected pixels will fit into a square
108 specified by points (xcenter-r, ycenter-r, xcenter+r, ycenter+r), inclusive.
111 --------------------------------------------------------------------------------
112 void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
113 GP_Size r, GP_Pixel pixel);
114 --------------------------------------------------------------------------------
116 Draws a filled circle.
118 The set of pixels affected by 'GP_FillCircle()' is exactly the same as if
119 drawing the circle boundary using 'GP_Circle()' and then filling all pixels
120 within the boundary with the same color.
125 --------------------------------------------------------------------------------
126 void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
127 GP_Size r1, GP_Size r2, GP_Pixel pixel);
128 --------------------------------------------------------------------------------
130 Draws a ring (two circles centered at (xcenter, ycenter) with radii 'r1' and 'r2').
132 The result is exactly the same as calling 'GP_Circle()' with the same center
133 and appropriate radii.
136 --------------------------------------------------------------------------------
137 void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
138 GP_Size r1, GP_Size r2, GP_Pixel pixel);
139 --------------------------------------------------------------------------------
143 The smaller of r1 and r2 is used for inner radius and bigger one for outer
150 --------------------------------------------------------------------------------
151 void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
152 GP_Size a, GP_Size b, GP_Pixel pixel);
153 --------------------------------------------------------------------------------
155 Draws an axis-aligned ellipse.
157 The ellipse is drawn so that all affected pixels will fit into a rectangle
158 specified by points (xcenter-a, ycenter-b, xcenter+a, ycenter+b), inclusive.
161 --------------------------------------------------------------------------------
162 void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
163 GP_Size a, GP_Size b, GP_Pixel pixel);
164 --------------------------------------------------------------------------------
166 Draws a filled axis-aligned ellipse.
172 --------------------------------------------------------------------------------
173 void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
174 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
176 --------------------------------------------------------------------------------
181 --------------------------------------------------------------------------------
182 void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
183 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
185 --------------------------------------------------------------------------------
187 Draws a filled triangle.
193 --------------------------------------------------------------------------------
194 void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
195 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
197 void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
198 GP_Size w, GP_Size h, GP_Pixel pixel);
200 void GP_Rect(GP_Context *context, GP_Coord x0, GP_Coord y0,
201 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
202 --------------------------------------------------------------------------------
206 The 'GP_RectXYXY()' expects two corner points (x0, y0), and (x1, y1).
207 The 'GP_RectXYWH()' expects a corner point (x0, y0), width and height.
208 The 'GP_Rect()' function is an alias for 'GP_RectXYXY()'.
211 --------------------------------------------------------------------------------
212 void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
213 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
215 void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
216 GP_Size w, GP_Size h, GP_Pixel pixel);
218 void GP_FillRect(GP_Context *context, GP_Coord x0, GP_Coord y0,
219 GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
220 --------------------------------------------------------------------------------
222 Draws a filled rectangle.
224 The 'GP_RectXYXY' fills an area between corner points (x0, y0) and (x1, y1),
226 The 'GP_RectXYWH' fills an area starting from (x0, y0) with specified width
227 and height, i.e. from (x0, y0) to (x0 + w, x1 + y), NOT inclusive.
228 The 'GP_FillRect()' functions is an alias for 'GP_FillRectXYXY()'.
234 --------------------------------------------------------------------------------
235 void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
236 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
237 GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
238 --------------------------------------------------------------------------------
243 --------------------------------------------------------------------------------
244 void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
245 GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
246 GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
247 --------------------------------------------------------------------------------
249 Draws a filled tetragon.
255 --------------------------------------------------------------------------------
256 void GP_Polygon(GP_Context *context, unsigned int vertex_count,
257 const GP_Coord *xy, GP_Pixel pixel);
258 --------------------------------------------------------------------------------
263 --------------------------------------------------------------------------------
264 void GP_FillPolygon(GP_Context *context, unsigned int vertex_count,
265 const GP_Coord *xy, GP_Pixel pixel);
266 --------------------------------------------------------------------------------
268 Draws a filled polygon.
270 The coordinages are passed in [x0, y0, x1, y1, ...] order, the vertex count
271 describes a number of nodes, i.e. half of the size of the array.