diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-11-13 13:17:31 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-11-13 13:19:18 -0800 |
| commit | 957f8649c2a21cf95ab13d6ea4d5b59ee9ada65f (patch) | |
| tree | d90cb1fd7aeb57fcd6ae59a84cb859599cf8928b /src/cairo-tests/multishape.cpp | |
| parent | 04cdffeed4d3c58c81f79e1c3869e3cb58f81cb7 (diff) | |
Add bubbles test and the start of a multishape test
Diffstat (limited to 'src/cairo-tests/multishape.cpp')
| -rw-r--r-- | src/cairo-tests/multishape.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/cairo-tests/multishape.cpp b/src/cairo-tests/multishape.cpp new file mode 100644 index 0000000..f3146ce --- /dev/null +++ b/src/cairo-tests/multishape.cpp @@ -0,0 +1,47 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cairo.h> +#include <math.h> + +#include "caskbench.h" + +static int element_spacing; +static int num_x_elements; +static int num_y_elements; + +int +ca_setup_multishape(caskbench_context_t *ctx) +{ + if (ctx->size < 0) + return 0; + + element_spacing = sqrt( ((double)ctx->canvas_width * ctx->canvas_height) / ctx->size); + num_x_elements = ctx->canvas_width / element_spacing; + num_y_elements = ctx->canvas_height / element_spacing; + + return 1; +} + +void +ca_teardown_multishape(void) +{ +} + +int +ca_test_multishape(caskbench_context_t *ctx) +{ + int i, j, x, y, r; + + r = 0.9 * element_spacing / 2; + for (j=0; j<num_y_elements; j++) { + y = j * element_spacing; + for (i=0; i<num_x_elements; i++) { + x = i * element_spacing; + randomize_color (ctx->cr); + cairo_arc (ctx->cr, x, y, r, 0, 2*M_PI); + cairo_fill (ctx->cr); + } + } + return 1; +} + |