summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/roundrect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-tests/roundrect.cpp')
-rw-r--r--src/cairo-tests/roundrect.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/cairo-tests/roundrect.cpp b/src/cairo-tests/roundrect.cpp
index 79f573c..8141d15 100644
--- a/src/cairo-tests/roundrect.cpp
+++ b/src/cairo-tests/roundrect.cpp
@@ -1,15 +1,18 @@
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>
#include "caskbench.h"
-static int line_length;
-
int
ca_setup_roundrect(caskbench_context_t *ctx)
{
- line_length = 60;
+ cairo_t *cr = ctx->cairo_cr;
+
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_BEST);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
return 1;
}
@@ -34,17 +37,20 @@ rounded_rectangle (cairo_t *cr,
int
ca_test_roundrect(caskbench_context_t *ctx)
{
- int i, w, x, y;
+ int i;
+ double line_width, x, y;
cairo_t *cr = ctx->cairo_cr;
for (i=0; i<ctx->size; i++) {
randomize_color (cr);
- x = 10 + ((double)ctx->canvas_width*rand())/RAND_MAX;
- y = 10 + ((double)ctx->canvas_height*rand())/RAND_MAX;;
- w = ((double)ctx->size*rand())/RAND_MAX + 1;
+ x = 10 + trunc( (((double)ctx->canvas_width-20.0)*rand())/RAND_MAX );
+ y = 10 + trunc( (((double)ctx->canvas_height-20.0)*rand())/RAND_MAX );
rounded_rectangle (cr, x, y, 100, 40, 4);
- cairo_set_line_width (cr, w);
+
+ line_width = trunc( ((double)ctx->size*rand())/RAND_MAX ) + 1;
+ cairo_set_line_width (cr, line_width);
+
cairo_stroke (cr);
}
return 1;