1 /****************************************************************************
2 * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007
3 ****************************************************************************
4 * rrd_gfx.h generic graphics adapter library
5 ****************************************************************************/
9 #define LIBART_COMPILATION
13 #define gamma libart_gamma
14 #include <libart_lgpl/libart.h>
15 #include <libart_lgpl/art_rgba.h>
16 #include "art_rgba_svp.h"
22 enum gfx_if_en { IF_PNG = 0, IF_SVG, IF_EPS, IF_PDF };
23 enum gfx_en { GFX_LINE = 0, GFX_AREA, GFX_TEXT };
24 enum gfx_h_align_en { GFX_H_NULL = 0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER };
25 enum gfx_v_align_en { GFX_V_NULL = 0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER };
26 enum gfx_aa_type_en { AA_NORMAL = 0, AA_LIGHT, AA_NONE };
27 typedef unsigned long gfx_color_t;
29 typedef struct gfx_node_t {
30 enum gfx_en type; /* type of graph element */
31 gfx_color_t color; /* color of element 0xRRGGBBAA alpha 0xff is solid */
32 double size; /* font size, line width */
33 double dash_on, dash_off; /* dash line fragments lengths */
37 char *filename; /* font or image filename */
39 ArtVpath *path; /* path */
40 double x, y; /* position */
41 double angle; /* text angle */
42 enum gfx_h_align_en halign; /* text alignement */
43 enum gfx_v_align_en valign; /* text alignement */
45 struct gfx_node_t *next;
49 typedef struct gfx_canvas_t {
50 struct gfx_node_t *firstnode;
51 struct gfx_node_t *lastnode;
52 enum gfx_if_en imgformat; /* image format */
53 int interlaced; /* will the graph be interlaced? */
54 double zoom; /* zoom for graph */
55 double font_aa_threshold; /* no anti-aliasing for sizes <= */
56 enum gfx_aa_type_en aa_type; /* anti-aliasing type (normal/light/none) */
59 gfx_canvas_t *gfx_new_canvas(
62 /* create a new line */
63 gfx_node_t *gfx_new_line(
64 gfx_canvas_t * canvas,
72 gfx_node_t *gfx_new_dashed_line(
73 gfx_canvas_t * canvas,
83 /* create a new area */
84 gfx_node_t *gfx_new_area(
85 gfx_canvas_t * canvas,
94 /* add a point to a line or to an area */
100 /* close current path so it ends at the same point as it started */
105 /* create a text node */
106 gfx_node_t *gfx_new_text(
107 gfx_canvas_t * canvas,
115 enum gfx_h_align_en h_align,
116 enum gfx_v_align_en v_align,
119 /* measure width of a text string */
120 double gfx_get_text_width(
121 gfx_canvas_t * canvas,
129 /* save image to file */
131 gfx_canvas_t * canvas,
134 gfx_color_t background,
137 /* free memory used by nodes this will also remove memory required for
138 node chain and associated material */
140 gfx_canvas_t * canvas);
145 gfx_canvas_t * canvas,
148 gfx_color_t background,
150 double gfx_get_text_width_libart(
151 gfx_canvas_t * canvas,
161 gfx_canvas_t * canvas,
164 gfx_color_t background,
169 gfx_canvas_t * canvas,
172 gfx_color_t background,
177 gfx_canvas_t * canvas,
180 gfx_color_t background,