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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
* Copyright © 2009 Nis Martensen
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of the copyright holder
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The
* copyright holder makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without
* express or implied warranty.
*
* THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Nis Martensen <nis.martensen@web.de>
*/
#include "cairo-test.h"
#define SIZE 20
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
/* We draw in the default black, so paint white first. */
cairo_save (cr);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
cairo_paint (cr);
cairo_restore (cr);
/* subpath starts with cairo_move_to */
cairo_new_sub_path (cr);
cairo_move_to (cr, SIZE, SIZE);
cairo_rel_line_to (cr, SIZE, 0);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, 0.5 * SIZE, SIZE);
/* subpath starts with cairo_line_to */
cairo_new_sub_path (cr);
cairo_line_to (cr, SIZE, 3 * SIZE);
cairo_rel_line_to (cr, SIZE, 0);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, 0, SIZE);
/* subpath starts with cairo_curve_to */
cairo_new_sub_path (cr);
cairo_curve_to (cr,
SIZE, 5 * SIZE,
1.5 * SIZE, 6 * SIZE,
2 * SIZE, 5 * SIZE);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.5 * SIZE, SIZE);
/* subpath starts with cairo_arc */
cairo_new_sub_path (cr);
cairo_arc (cr,
1.5 * SIZE, 7 * SIZE,
0.5 * SIZE,
M_PI, 2 * M_PI);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.7 * SIZE, 0.7 * SIZE);
/* subpath starts with cairo_arc_negative */
cairo_new_sub_path (cr);
cairo_arc_negative (cr,
1.5 * SIZE, 9 * SIZE,
0.5 * SIZE,
M_PI, 2 * M_PI);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.8 * SIZE, 0.3 * SIZE);
cairo_stroke (cr);
return CAIRO_TEST_SUCCESS;
}
CAIRO_TEST (close_path_current_point,
"Test some corner cases related to cairo path operations and the current point",
"path", /* keywords */
NULL, /* requirements */
3 * SIZE, 11 * SIZE,
NULL, draw)
|