1
/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
2
/*
3
 * Copyright 2010 Andrea Canciani
4
 *
5
 * Permission is hereby granted, free of charge, to any person
6
 * obtaining a copy of this software and associated documentation
7
 * files (the "Software"), to deal in the Software without
8
 * restriction, including without limitation the rights to use, copy,
9
 * modify, merge, publish, distribute, sublicense, and/or sell copies
10
 * of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 * SOFTWARE.
24
 *
25
 * Author: Andrea Canciani <ranma42@gmail.com>
26
 */
27

            
28
#include "cairo-test.h"
29

            
30
#define SIZE 32
31

            
32
/*
33
  When cairo_arc is used to draw an arc of more than 2pi radians
34
  (i.e. a circle "looping over itself"), various different behaviors
35
  are possible:
36

            
37
  - draw exactly a circle (an arc of 2pi radians)
38

            
39
  - draw an arc such that the current point is the expected one and
40
    that does at least a complete circle (an arc of [2pi, 4pi)
41
    radians)
42

            
43
  - draw an arc with the original number of loops
44

            
45
  This test produces different results for each of these three cases.
46
*/
47

            
48
static cairo_test_status_t
49
3
draw (cairo_t *cr, int width, int height)
50
{
51
3
    double dashes[] = { 0.3, 7 };
52

            
53
3
    cairo_set_source_rgb (cr, 1, 1, 1);
54
3
    cairo_paint (cr);
55

            
56
3
    cairo_save (cr);
57

            
58
3
    cairo_translate (cr, SIZE * .5, SIZE * .5);
59
3
    cairo_scale (cr, SIZE * 3 / 8., SIZE * 3 / 8.);
60

            
61
3
    cairo_arc (cr, 0, 0, 1, 0, 11 * M_PI);
62

            
63
3
    cairo_set_line_width (cr, 8. / SIZE);
64

            
65
3
    cairo_set_source_rgb (cr, 0, 0, 0);
66
3
    cairo_set_dash (cr, dashes, 2, 0);
67
3
    cairo_stroke (cr);
68

            
69
3
    cairo_restore (cr);
70

            
71
3
    return CAIRO_TEST_SUCCESS;
72
}
73

            
74
1
CAIRO_TEST (arc_looping_dash,
75
	    "Test cairo_arc for angles describing more than a complete circle",
76
	    "arc", /* keywords */
77
	    NULL, /* requirements */
78
	    SIZE, SIZE,
79
	    NULL, draw)