debian: Add graphviz dependency
[gfxprim/pasky.git] / doc / basic_types.txt
blob11ff214b7c62c90587ad4008bf9750448464f39d
1 Basic types
2 -----------
3 Coordinates and Size and Length
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 Most of the drawing functions use typedefed 'GP_Coord' and 'GP_Size' integer
7 types for parameters.
9 The 'GP_Coord' is signed integer which is used for coordinates and the
10 'GP_Size' is unsigned integer type used for object size, length and so.
12 Pixel
13 ~~~~~
15 Pixel value in 'GFXprim' is an integer big enough to hold the actual pixel
16 values. The default typedef for 'GP_Pixel' is set to 32 bit integer, which may
17 be changed at compile time to support colors with more than 10 bits per
18 channel. The 'GP_Pixel' is thus used as opaque value big enough to hold any
19 supported pixel value.
21 [[Color]]
22 Color
23 ~~~~~
25 The 'GP_Color' enumeration holds symbolic constants for basic colors.
27 A 'GP_Color' can be converted into a 'GP_Pixel' for a given 'GP_PixelType'.
28 Symbolic values can also be converted to/from strings (color name in English).
30 The 'GP_Color' enum is defined as follows:
32 [source,c]
33 --------------------------------------------------------------------------------
34 typedef enum GP_Color {
35         GP_COL_INVALID = -1,
37         /* full-intensity RGB and CMYK */
38         GP_COL_BLACK,
39         GP_COL_RED,
40         GP_COL_GREEN,
41         GP_COL_BLUE,
42         GP_COL_YELLOW,
43         GP_COL_CYAN,
44         GP_COL_MAGENTA,
46         /* various common mixes */
47         GP_COL_BROWN,
48         GP_COL_ORANGE,
49         GP_COL_GRAY_DARK,       /* exactly half RGB values of white */
50         GP_COL_GRAY_LIGHT,
51         GP_COL_PURPLE,
53         GP_COL_WHITE,           /* full-intensity white */
54         GP_COL_MAX,
55 } GP_Color;
56 --------------------------------------------------------------------------------
58 [source,c]
59 --------------------------------------------------------------------------------
60 #include <core/GP_Color.h>
61 /* or */
62 #include <GP.h>
64 GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type);
65 GP_Pixel GP_ColorToContextPixel(GP_Color color, GP_Context *context);
67 GP_Color GP_ColorNameToColor(const char *color_name);
68 const char *GP_ColorToColorName(GP_Color color);
70 bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
71                          GP_Pixel *pixel);
72 bool GP_ColorNameToContextPixel(const char *color_name, GP_Context *context,
73                                 GP_Pixel *pixel);
74 --------------------------------------------------------------------------------
76 Functions for conversion between colors, pixels and color names. The last two
77 returns true if color with such name was found.
79 [source,c]
80 --------------------------------------------------------------------------------
81 #include <core/GP_Color.h>
82 /* or */
83 #include <GP.h>
85 void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type);
86 void GP_ColorLoadContextPixels(GP_Pixel pixels[], GP_Context *context);
87 --------------------------------------------------------------------------------
89 Loads array of 'GP_Pixel' of size 'GP_COL_MAX', the array is then used with
90 the GP_Color enum as 'pixels[GP_COL_BLACK]'.