X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_gfx.h;h=81020adb44cb140efa662feab80a5fdfb7547259;hb=32bff69819374d9875577fe106dee60af473637b;hp=808b7c40a84a9545c44558d1ebd5077ad2e9f085;hpb=a1fe8fd19bb4f558150e52c0624869667b739877;p=rrdtool.git diff --git a/src/rrd_gfx.h b/src/rrd_gfx.h index 808b7c4..81020ad 100644 --- a/src/rrd_gfx.h +++ b/src/rrd_gfx.h @@ -9,6 +9,7 @@ #define LIBART_COMPILATION #include +enum gfx_if_en {IF_PNG=0,IF_SVG,IF_EPS,IF_PDF}; enum gfx_en { GFX_LINE=0,GFX_AREA,GFX_TEXT }; enum gfx_h_align_en { GFX_H_NULL=0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER }; enum gfx_v_align_en { GFX_V_NULL=0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER }; @@ -18,13 +19,16 @@ typedef struct gfx_node_t { enum gfx_en type; /* type of graph element */ gfx_color_t color; /* color of element 0xRRGGBBAA alpha 0xff is solid*/ double size; /* font size, line width */ + double dash_on, dash_off; /* dash line fragments lengths */ ArtVpath *path; /* path */ + int closed_path; int points; int points_max; ArtSVP *svp; /* svp */ char *filename; /* font or image filename */ char *text; double x,y; /* position */ + double angle; /* text angle */ enum gfx_h_align_en halign; /* text alignement */ enum gfx_v_align_en valign; /* text alignement */ double tabwidth; @@ -36,6 +40,9 @@ typedef struct gfx_canvas_t { struct gfx_node_t *firstnode; struct gfx_node_t *lastnode; + enum gfx_if_en imgformat; /* image format */ + int interlaced; /* will the graph be interlaced? */ + double zoom; /* zoom for graph */ } gfx_canvas_t; @@ -43,20 +50,29 @@ gfx_canvas_t *gfx_new_canvas (void); /* create a new line */ gfx_node_t *gfx_new_line (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, + double X0, double Y0, + double X1, double Y1, double width, gfx_color_t color); +gfx_node_t *gfx_new_dashed_line (gfx_canvas_t *canvas, + double X0, double Y0, + double X1, double Y1, + double width, gfx_color_t color, + double dash_on, double dash_off); + /* create a new area */ gfx_node_t *gfx_new_area (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, - double x2, double y2, + double X0, double Y0, + double X1, double Y1, + double X2, double Y2, gfx_color_t color); /* add a point to a line or to an area */ int gfx_add_point (gfx_node_t *node, double x, double y); +/* close current path so it ends at the same point as it started */ +void gfx_close_path (gfx_node_t *node); + /* create a text node */ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, @@ -68,23 +84,41 @@ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, char* text); /* measure width of a text string */ -double gfx_get_text_width ( double start, char* font, double size, +double gfx_get_text_width ( gfx_canvas_t *canvas, + double start, char* font, double size, double tabwidth, char* text); - - -/* turn graph into a png image */ -int gfx_render_png (gfx_canvas_t *canvas, +/* save image to file */ +int gfx_render (gfx_canvas_t *canvas, art_u32 width, art_u32 height, - double zoom, gfx_color_t background, FILE *fo); - - + /* free memory used by nodes this will also remove memory required for node chain and associated material */ int gfx_destroy (gfx_canvas_t *canvas); -#endif +/* PNG support*/ +int gfx_render_png (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fo); +double gfx_get_text_width_libart ( gfx_canvas_t *canvas, + double start, char* font, double size, + double tabwidth, char* text); + +/* SVG support */ +int gfx_render_svg (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fo); + +/* EPS support */ +int gfx_render_eps (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fo); +/* PDF support */ +int gfx_render_pdf (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fo); +#endif