summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/stroke.cpp
blob: ee8cf723093e6668694a823bf8d7ad17266043b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>

#include "caskbench.h"

static int line_length;

int
ca_setup_stroke(caskbench_context_t *ctx)
{
    line_length = 60;
    return 1;
}

void
ca_teardown_stroke(void)
{
}

int
ca_test_stroke(caskbench_context_t *ctx)
{
    int i, x, w, prev_w;
    cairo_t *cr = ctx->cairo_cr;

    x = 0;
    prev_w = 0;
    for (i=0; i<ctx->size; i++) {
        randomize_color (cr);
        w = ((double)ctx->size*rand())/RAND_MAX + 1;
        x += 4 + (prev_w + w)/2.0;
        cairo_move_to (cr, x, 10);
        cairo_line_to (cr, x, 10 + line_length);
        cairo_set_line_width (cr, w);
        cairo_stroke (cr);
        prev_w = w;
    }
    return 1;
}