summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/rectangles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-tests/rectangles.cpp')
-rw-r--r--src/cairo-tests/rectangles.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cairo-tests/rectangles.cpp b/src/cairo-tests/rectangles.cpp
index a53a155..803cd31 100644
--- a/src/cairo-tests/rectangles.cpp
+++ b/src/cairo-tests/rectangles.cpp
@@ -1,3 +1,4 @@
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>
@@ -7,6 +8,12 @@
int
ca_setup_rectangles(caskbench_context_t *ctx)
{
+ cairo_t *cr = ctx->cairo_cr;
+
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+ cairo_set_line_width (cr, 1);
return 1;
}
@@ -18,18 +25,19 @@ ca_teardown_rectangles(void)
int
ca_test_rectangles(caskbench_context_t *ctx)
{
- int i, w, h, x, y;
+ int i;
+ double w, h, x, y;
cairo_t *cr = ctx->cairo_cr;
for (i=0; i<ctx->size; i++) {
randomize_color (cr);
- w = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX + 1;
- h = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX + 1;
- x = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX;
- y = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX;
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_line_width (cr, 1);
+ w = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX ) + 1;
+ h = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX ) + 1;
+ x = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX );
+ y = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX );
+ cairo_rectangle(cr, x+1, y+1, w, h);
+
cairo_stroke (cr);
}
return 1;