summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/multishape.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-03-06 17:24:41 -0800
committerBryce Harrington <b.harrington@samsung.com>2014-03-06 17:24:41 -0800
commit9959f05f3fe0d2b0dc5b0c1aa38c7b8d870c63b9 (patch)
tree12f2eb3a085fe94dd4f70e6a255ac7c2a9660b32 /src/cairo-tests/multishape.cpp
parent652005fe1f931c75642c8d597f431a138d431f5a (diff)
multishape: Add triangle, square, star, etc.
Diffstat (limited to 'src/cairo-tests/multishape.cpp')
-rw-r--r--src/cairo-tests/multishape.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/cairo-tests/multishape.cpp b/src/cairo-tests/multishape.cpp
index 5c22a3e..e3a1930 100644
--- a/src/cairo-tests/multishape.cpp
+++ b/src/cairo-tests/multishape.cpp
@@ -9,6 +9,20 @@ static int element_spacing;
static int num_x_elements;
static int num_y_elements;
+static int star_points[11][2] = {
+ { 0, 85 },
+ { 75, 75 },
+ { 100, 10 },
+ { 125, 75 },
+ { 200, 85 },
+ { 150, 125 },
+ { 160, 190 },
+ { 100, 150 },
+ { 40, 190 },
+ { 50, 125 },
+ { 0, 85 }
+};
+
int
ca_setup_multishape(caskbench_context_t *ctx)
{
@@ -30,7 +44,7 @@ ca_teardown_multishape(void)
int
ca_test_multishape(caskbench_context_t *ctx)
{
- int i, j, x, y, r;
+ int i, j, x, y, r, p, shape;
cairo_t *cr = ctx->cairo_cr;
r = 0.9 * element_spacing / 2;
@@ -38,9 +52,48 @@ ca_test_multishape(caskbench_context_t *ctx)
y = j * element_spacing;
for (i=0; i<num_x_elements; i++) {
x = i * element_spacing;
+
randomize_color (cr);
- cairo_arc (cr, x, y, r, 0, 2*M_PI);
- cairo_fill (cr);
+
+ shape = (4.0 * rand())/RAND_MAX;
+ switch (shape) {
+ case 0:
+ // Circle
+ cairo_arc (cr, x+r, y+r, r, 0, 2*M_PI);
+ cairo_fill (cr);
+ break;
+
+ case 1:
+ // Rectangle
+ cairo_rectangle (cr, x, y, 2*r, 2*r);
+ cairo_fill (cr);
+ break;
+
+ case 2:
+ // Triangle
+ cairo_move_to (cr, x, y+2*r);
+ cairo_rel_line_to (cr, 2*r, 0);
+ cairo_rel_line_to (cr, -r, -2*r);
+ cairo_fill (cr);
+ break;
+
+ case 3:
+ // Star
+ cairo_move_to (cr, x, y);
+ for (p = 0; p < 10; p++ ) {
+ int px = x + 2*r * star_points[p][0]/200.0;
+ int py = y + 2*r * star_points[p][1]/200.0;
+ if (p == 0)
+ cairo_move_to (cr, px, py);
+ else
+ cairo_line_to(cr, px, py);
+ }
+ cairo_close_path(cr);
+ break;
+
+ default:
+ break;
+ }
}
}
return 1;