Updated docs to match the code.
[gfxprim.git] / doc / basic_types.txt
blobefc9c7bdfef50a08f1bbd4212d79fbfd70325af4
1 Basic types
2 -----------
3 Return Code
4 ~~~~~~~~~~~
6 Some gfxprim function returns one of following return codes (may be removed in
7 future):
9 [source,c]
10 --------------------------------------------------------------------------------
11 typedef enum GP_RetCode {
12         GP_ESUCCESS,
13         GP_EINVAL,
14         GP_ENOIMPL,
15         GP_EUNPRECISE,
16         GP_ENULLPTR,            /* some argument was unexpectedly NULL */
17         GP_EBACKENDLOST,
18         GP_EBADCONTEXT,         /* context contains invalid data */
19         GP_EBADFILE,            /* error in file, or bad file format */
20         GP_ENOENT,              /* no such file or another object */
21         GP_ENOMEM,              /* not enough memory */
22         GP_EMAX,
23 } GP_RetCode;
24 --------------------------------------------------------------------------------
26 Return codes could be translated into an error messages.
28 [source,c]
29 --------------------------------------------------------------------------------
30 const char *GP_RetCodeName(GP_RetCode code);
31 --------------------------------------------------------------------------------
33 Coord and Size
34 ~~~~~~~~~~~~~~
35 For drawing API there are two integer types defined the 'GP_Coord' for
36 coordinates and 'GP_Size' for size, length or so.
39 Color and pixel types
40 ~~~~~~~~~~~~~~~~~~~~~
42 The color, in gfxprim is enumeration of symbolic color names while pixel is
43 integer value or you may say color in format of the target bitmap.
45 Color could be converted into given pixel type which will result in integer
46 value suitable for usage with drawing functions. The color could be also
47 converted to color name (C string in English language) and C string may be
48 matched against table of color names.
50 As all drawing functions works with pixel rather than color the color must be
51 converted before using function to draw a shape into a bitmap.
53 The color is defined as follows:
55 [source,c]
56 --------------------------------------------------------------------------------
57 typedef enum GP_Color {
58         GP_COL_INVALID = -1,
59         GP_COL_BLACK,
60         ...
61 } GP_Color;
62 --------------------------------------------------------------------------------
64 Color and Pixel conversion functions, the last one returns 'true' in case of
65 successful match and conversion and false otherwise.
67 [source,c]
68 --------------------------------------------------------------------------------
69 #include <core/GP_Color.h>
71 GP_Pixel GP_ColorToPixel(GP_Context *context, GP_Color color);
73 GP_Color GP_ColorNameToColor(const char *color_name);
75 const char *GP_ColorToColorName(GP_Color color);
77 bool GP_ColorNameToPixel(GP_Context *context, const char *color_name,
78                          GP_Pixel *pixel);
79 --------------------------------------------------------------------------------