1 /****************************************************************************
2 * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007
3 ****************************************************************************
4 * rrd_gfx.h generic graphics adapter library
5 ****************************************************************************/
7 #ifndef RRD_GFX_H
8 #define RRD_GFX_H
10 #define y0 cairo_y0
11 #define y1 cairo_y1
12 #define index cairo_index
14 #include <cairo-pdf.h>
15 #include <cairo-svg.h>
16 #include <cairo-ps.h>
17 #include <pango/pangocairo.h>
19 enum gfx_if_en { IF_PNG = 0, IF_SVG, IF_EPS, IF_PDF };
20 enum gfx_en { GFX_LINE = 0, GFX_AREA, GFX_TEXT };
21 enum gfx_h_align_en { GFX_H_NULL = 0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER };
22 enum gfx_v_align_en { GFX_V_NULL = 0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER };
24 /* cairo color components */
25 typedef struct gfx_color_t {
26 double red;
27 double green;
28 double blue;
29 double alpha;
30 } gfx_color_t;
33 /* create a new line */
34 void gfx_line(
35 cairo_t * cr,
36 double X0,
37 double Y0,
38 double X1,
39 double Y1,
40 double width,
41 gfx_color_t color);
43 void gfx_dashed_line(
44 cairo_t * cr,
45 double X0,
46 double Y0,
47 double X1,
48 double Y1,
49 double width,
50 gfx_color_t color,
51 double dash_on,
52 double dash_off);
54 /* create a new area */
55 void gfx_new_area(
56 cairo_t * cr,
57 double X0,
58 double Y0,
59 double X1,
60 double Y1,
61 double X2,
62 double Y2,
63 gfx_color_t color);
65 /* add a point to a line or to an area */
66 void gfx_add_point(
67 cairo_t * cr,
68 double x,
69 double y);
71 /* close current path so it ends at the same point as it started */
72 void gfx_close_path(
73 cairo_t * cr);
76 /* create a text node */
77 void gfx_text(
78 cairo_t * cr,
79 double x,
80 double y,
81 gfx_color_t color,
82 char *font,
83 double size,
84 double tabwidth,
85 double angle,
86 enum gfx_h_align_en h_align,
87 enum gfx_v_align_en v_align,
88 const char *text);
90 /* measure width of a text string */
91 double gfx_get_text_width(
92 cairo_t * cr,
93 double start,
94 char *font,
95 double size,
96 double tabwidth,
97 char *text);
100 /* convert color */
101 gfx_color_t gfx_hex_to_col(
102 long unsigned int);
103 void gfx_line_fit(
104 cairo_t *,
105 double *,
106 double *);
107 void gfx_area_fit(
108 cairo_t *,
109 double *,
110 double *);
111 #endif