2 * Copyright © 2006 Jeff Muizelaar
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Jeff Muizelaar not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Jeff Muizelaar makes no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * JEFF MUIZELAAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL JEFF MUIZELAAR BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Jeff Muizelaar <jeff@infidigm.net>
26 #include "cairo-test.h"
29 #define LINE_WIDTH 6.0
31 static cairo_test_status_t
32 draw (cairo_t *cr, int width, int height)
34 const cairo_line_cap_t cap[] = { CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_SQUARE, CAIRO_LINE_CAP_BUTT };
36 double dash[] = {2, 2};
37 double dash_long[] = {6, 6};
39 cairo_set_source_rgb (cr, 1, 0, 0);
41 for (i = 0; i < ARRAY_LENGTH (cap); i++) {
44 cairo_set_line_cap (cr, cap[i]);
46 /* simple degenerate paths */
47 cairo_set_line_width (cr, LINE_WIDTH);
48 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
49 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
52 cairo_translate (cr, 0, 3*PAD);
53 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
54 cairo_close_path (cr);
57 /* degenerate paths starting with dash on */
58 cairo_set_dash (cr, dash, 2, 0.);
60 cairo_translate (cr, 0, 3*PAD);
61 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
62 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
65 cairo_translate (cr, 0, 3*PAD);
66 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
67 cairo_close_path (cr);
70 /* degenerate paths starting with dash off */
71 /* these should not draw anything */
72 cairo_set_dash (cr, dash, 2, 2.);
74 cairo_translate (cr, 0, 3*PAD);
75 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
76 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
79 cairo_translate (cr, 0, 3*PAD);
80 cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH);
81 cairo_close_path (cr);
84 /* this should draw a single degenerate sub-path
85 * at the end of the path */
86 cairo_set_dash (cr, dash_long, 2, 6.);
88 cairo_translate (cr, 0, 3*PAD);
89 cairo_move_to (cr, LINE_WIDTH + 6.0, LINE_WIDTH);
90 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
93 /* this should draw a single degenerate sub-path
94 * at the end of the path. The difference between this
95 * and the above is that this ends with a degenerate sub-path*/
96 cairo_set_dash (cr, dash_long, 2, 6.);
98 cairo_translate (cr, 0, 3*PAD);
99 cairo_move_to (cr, LINE_WIDTH + 6.0, LINE_WIDTH);
100 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
101 cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH);
106 cairo_translate (cr, PAD+LINE_WIDTH+PAD, 0);
108 return CAIRO_TEST_SUCCESS;
111 CAIRO_TEST (degenerate_path,
112 "Tests the behaviour of degenerate paths with different cap types",
113 "degenerate", /* keywords */
114 NULL, /* requirements */
115 3*(PAD+LINE_WIDTH+PAD), 8*(LINE_WIDTH+PAD) + PAD,