X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_gfx.c;h=416b8a32ada2244d9567498688c920e6b526afb7;hb=0fdd2b797ac6e498415c1910110806f37ab9bf1c;hp=fa938617f51ba22d763332829d062fdd20458ddf;hpb=219fd9224e3117dcf59df8818d4e9e3eab26022a;p=rrdtool.git diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index fa93861..416b8a3 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 **************************************************************************** * rrd_gfx.c graphics wrapper for rrdtool **************************************************************************/ @@ -105,6 +105,42 @@ void gfx_add_point( cairo_line_to(cr, x, y); } +/* add a point to a line or to an area */ +void gfx_add_rect_fadey( + image_desc_t *im, + double x1,double y1, + double x2,double y2, + double py, + gfx_color_t color1, + gfx_color_t color2, + double height) +{ + cairo_t *cr = im->cr; + + cairo_new_path(cr); + gfx_area_fit(im, &x1, &y1); + gfx_area_fit(im, &x2, &y2); + cairo_line_to(cr, x1, y1); + cairo_line_to(cr, x1, y2); + cairo_line_to(cr, x2, y2); + cairo_line_to(cr, x2, y1); + cairo_close_path(cr); + cairo_pattern_t* p; + if (height < 0) { + p = cairo_pattern_create_linear(x1,y1,x2,y1+height); + } else if (height > 0) { + p = cairo_pattern_create_linear(x1,(y2+py)/2+height,x2,(y2+py)/2); + } else { + p = cairo_pattern_create_linear(x1,y1,x2,(y2+py)/2); + } + //cairo_pattern_t* p = cairo_pattern_create_linear(x1,py+50,x2,py); + cairo_pattern_add_color_stop_rgba(p, 1, color1.red,color1.green,color1.blue,color1.alpha); + cairo_pattern_add_color_stop_rgba(p, 0, color2.red,color2.green,color2.blue,color2.alpha); + cairo_set_source(cr, p); + cairo_pattern_destroy(p); + cairo_fill(cr); +} + void gfx_close_path( image_desc_t *im) { @@ -124,7 +160,7 @@ static PangoLayout *gfx_prep_text( const char *text) { PangoLayout *layout = im->layout; - PangoFontDescription *pfd; + const PangoFontDescription *pfd; cairo_t *cr = im->cr; static double last_tabwidth = -1;