1 /****************************************************************************
2 * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2001
3 ****************************************************************************
4 * rrd_gfx.h generic graphics adapter library
5 ****************************************************************************/
9 #define LIBART_COMPILATION
10 #include <libart_lgpl/libart.h>
12 enum gfx_if_en {IF_PNG=0,IF_SVG,IF_EPS,IF_PDF};
13 enum gfx_en { GFX_LINE=0,GFX_AREA,GFX_TEXT };
14 enum gfx_h_align_en { GFX_H_NULL=0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER };
15 enum gfx_v_align_en { GFX_V_NULL=0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER };
16 typedef unsigned long gfx_color_t;
18 typedef struct gfx_node_t {
19 enum gfx_en type; /* type of graph element */
20 gfx_color_t color; /* color of element 0xRRGGBBAA alpha 0xff is solid*/
21 double size; /* font size, line width */
22 double dash_on, dash_off; /* dash line fragments lengths */
23 ArtVpath *path; /* path */
27 ArtSVP *svp; /* svp */
28 char *filename; /* font or image filename */
30 double x,y; /* position */
31 double angle; /* text angle */
32 enum gfx_h_align_en halign; /* text alignement */
33 enum gfx_v_align_en valign; /* text alignement */
35 struct gfx_node_t *next;
39 typedef struct gfx_canvas_t
41 struct gfx_node_t *firstnode;
42 struct gfx_node_t *lastnode;
43 enum gfx_if_en imgformat; /* image format */
44 int interlaced; /* will the graph be interlaced? */
45 double zoom; /* zoom for graph */
48 gfx_canvas_t *gfx_new_canvas (void);
50 /* create a new line */
51 gfx_node_t *gfx_new_line (gfx_canvas_t *canvas,
54 double width, gfx_color_t color);
56 gfx_node_t *gfx_new_dashed_line (gfx_canvas_t *canvas,
59 double width, gfx_color_t color,
60 double dash_on, double dash_off);
62 /* create a new area */
63 gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
69 /* add a point to a line or to an area */
70 int gfx_add_point (gfx_node_t *node, double x, double y);
72 /* close current path so it ends at the same point as it started */
73 void gfx_close_path (gfx_node_t *node);
76 /* create a text node */
77 gfx_node_t *gfx_new_text (gfx_canvas_t *canvas,
78 double x, double y, gfx_color_t color,
79 char* font, double size,
80 double tabwidth, double angle,
81 enum gfx_h_align_en h_align,
82 enum gfx_v_align_en v_align,
85 /* measure width of a text string */
86 double gfx_get_text_width ( gfx_canvas_t *canvas,
87 double start, char* font, double size,
88 double tabwidth, char* text, int rotation);
90 /* save image to file */
91 int gfx_render (gfx_canvas_t *canvas,
92 art_u32 width, art_u32 height,
93 gfx_color_t background, FILE *fo);
95 /* free memory used by nodes this will also remove memory required for
96 node chain and associated material */
97 int gfx_destroy (gfx_canvas_t *canvas);
101 int gfx_render_png (gfx_canvas_t *canvas,
102 art_u32 width, art_u32 height,
103 gfx_color_t background, FILE *fo);
104 double gfx_get_text_width_libart ( gfx_canvas_t *canvas,
105 double start, char* font, double size,
106 double tabwidth, char* text, int rotation);
109 int gfx_render_svg (gfx_canvas_t *canvas,
110 art_u32 width, art_u32 height,
111 gfx_color_t background, FILE *fo);
114 int gfx_render_eps (gfx_canvas_t *canvas,
115 art_u32 width, art_u32 height,
116 gfx_color_t background, FILE *fo);
119 int gfx_render_pdf (gfx_canvas_t *canvas,
120 art_u32 width, art_u32 height,
121 gfx_color_t background, FILE *fo);