diff options
author | Benjamin Otte <otte@redhat.com> | 2010-06-23 15:25:59 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-06-23 15:25:59 +0200 |
commit | bfe2cc5ec45e1d557ca752884825d577ba1780eb (patch) | |
tree | d795c1ee16dd2bc35351a2e48359a6fc9ef6f89d | |
parent | b67f31dff8459aec2d468dbf4b314c419b1b89d8 (diff) |
perf-chart: Use Danielle Madelay's awesome chart gradients
-rw-r--r-- | perf/cairo-perf-chart.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/perf/cairo-perf-chart.c b/perf/cairo-perf-chart.c index ae2c07f0..69f76f67 100644 --- a/perf/cairo-perf-chart.c +++ b/perf/cairo-perf-chart.c @@ -307,17 +307,30 @@ test_background (struct chart *c, int test) cairo_fill (c->cr); } +static cairo_pattern_t * +get_report_pattern (const struct color *color, int x, int y, int w, int h) +{ + cairo_pattern_t *pattern; + + pattern = cairo_pattern_create_linear (x, y, x + w, y); + cairo_pattern_add_color_stop_rgb (pattern, 0.2, color->red, color->green, color->blue); + cairo_pattern_add_color_stop_rgb (pattern, 0.8, 1, 1, 1); + cairo_pattern_add_color_stop_rgb (pattern, 0.8, color->red, color->green, color->blue); + + return pattern; +} + static void add_chart (struct chart *c, int test, int report, double value) { double dx, dy, x; struct color color; + cairo_pattern_t *pattern; if (fabs (value) < 0.1) return; get_report_color (c, report, &color); - cairo_set_source_rgb (c->cr, color.red, color.green, color.blue); if (c->relative) { cairo_text_extents_t extents; @@ -330,6 +343,12 @@ add_chart (struct chart *c, int test, int report, double value) dx = c->width / (double) (c->num_tests * c->num_reports); x = dx * (c->num_reports * test + report - .5); + pattern = get_report_pattern (&color, + floor (x), c->height / 2., + floor (x + dx) - floor (x), + ceil (-dy*value - c->height/2.) + c->height/2.); + cairo_set_source (c->cr, pattern); + cairo_pattern_destroy (pattern); cairo_rectangle (c->cr, floor (x), c->height / 2., floor (x + dx) - floor (x), @@ -375,6 +394,12 @@ add_chart (struct chart *c, int test, int report, double value) dx = c->width / (double) (c->num_tests * (c->num_reports+1)); x = dx * ((c->num_reports+1) * test + report + .5); + pattern = get_report_pattern (&color, + floor (x), c->height, + floor (x + dx) - floor (x), + ceil (c->height - dy*value) - c->height); + cairo_set_source (c->cr, pattern); + cairo_pattern_destroy (pattern); cairo_rectangle (c->cr, floor (x), c->height, floor (x + dx) - floor (x), |