1 /****************************************************************************
2 * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2001
3 ****************************************************************************
4 * rrd_gfx.h generic graphics adapter library
5 ****************************************************************************/
7 #ifndef RRD_GFX_H
8 #define RRD_GFX_H
9 #define LIBART_COMPILATION
10 #include <libart.h>
12 enum gfx_en { GFX_LINE=0,GFX_AREA,GFX_TEXT };
13 enum gfx_h_align_en { GFX_H_NULL=0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER };
14 enum gfx_v_align_en { GFX_V_NULL=0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER };
15 typedef unsigned long gfx_color_t;
17 typedef struct gfx_node_t {
18 enum gfx_en type; /* type of graph element */
19 gfx_color_t color; /* color of element 0xRRGGBBAA alpha 0xff is solid*/
20 double size; /* font size, line width */
21 ArtVpath *path; /* path */
22 int points;
23 int points_max;
24 ArtSVP *svp; /* svp */
25 char *filename; /* font or image filename */
26 char *text;
27 double x,y; /* position */
28 enum gfx_h_align_en halign; /* text alignement */
29 enum gfx_v_align_en valign; /* text alignement */
30 double tabwidth;
31 struct gfx_node_t *next;
32 } gfx_node_t;
35 typedef struct gfx_canvas_t
36 {
37 struct gfx_node_t *firstnode;
38 struct gfx_node_t *lastnode;
39 } gfx_canvas_t;
42 gfx_canvas_t *gfx_new_canvas (void);
44 /* create a new line */
45 gfx_node_t *gfx_new_line (gfx_canvas_t *canvas,
46 double x0, double y0,
47 double x1, double y1,
48 double width, gfx_color_t color);
50 /* create a new area */
51 gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
52 double x0, double y0,
53 double x1, double y1,
54 double x2, double y2,
55 gfx_color_t color);
57 /* create an arc section (2*M_PI is full circle) */
58 gfx_node_t *gfx_arc_sect (gfx_canvas_t *canvas,
59 double centerx, double centery,
60 double radiusx, double radiusy,
61 double start, double end,
62 gfx_color_t color);
64 /* add a point to a line or to an area */
65 int gfx_add_point (gfx_node_t *node, double x, double y);
68 /* create a text node */
69 gfx_node_t *gfx_new_text (gfx_canvas_t *canvas,
70 double x, double y, gfx_color_t color,
71 char* font, double size,
72 double tabwidth, double angle,
73 enum gfx_h_align_en h_align,
74 enum gfx_v_align_en v_align,
75 char* text);
77 /* measure width of a text string */
78 double gfx_get_text_width ( double start, char* font, double size,
79 double tabwidth, char* text);
83 /* turn graph into a png image */
84 int gfx_render_png (gfx_canvas_t *canvas,
85 art_u32 width, art_u32 height,
86 double zoom,
87 gfx_color_t background, FILE *fo);
90 /* free memory used by nodes this will also remove memory required for
91 node chain and associated material */
92 int gfx_destroy (gfx_canvas_t *canvas);
94 #endif