2 * Copyright © 2005 Red Hat, Inc.
3 * Copyright © 2006 Red Hat, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * Red Hat, Inc. not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. Red Hat, Inc. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
16 * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
19 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Author: Carl D. Worth <cworth@cworth.org>
27 #include "cairo-test.h"
29 #define LINE_WIDTH 10.
30 #define SIZE (5 * LINE_WIDTH)
31 #define PAD (2 * LINE_WIDTH)
34 make_path (cairo_t *cr)
36 cairo_move_to (cr, 0., 0.);
37 cairo_rel_line_to (cr, 0., SIZE);
38 cairo_rel_line_to (cr, SIZE, 0.);
39 cairo_close_path (cr);
41 cairo_move_to (cr, 2 * LINE_WIDTH, 0.);
42 cairo_rel_line_to (cr, 3 * LINE_WIDTH, 0.);
43 cairo_rel_line_to (cr, 0., 3 * LINE_WIDTH);
46 static cairo_test_status_t
47 draw (cairo_t *cr, int width, int height)
49 /* First draw a checkered background */
50 cairo_test_paint_checkered (cr);
52 /* Then draw the original caps-joins test but with a bit of alphs thrown in. */
53 cairo_set_line_width (cr, LINE_WIDTH);
55 cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.5); /* 50% red */
56 cairo_translate (cr, PAD, PAD);
59 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
60 cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
63 cairo_set_source_rgba (cr, 0.0, 1.0, 0.0, 0.5); /* 50% green */
64 cairo_translate (cr, SIZE + PAD, 0.);
67 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
68 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
71 cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.5); /* 50% blue */
73 cairo_translate (cr, SIZE + PAD, 0.);
76 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
77 cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
80 return CAIRO_TEST_SUCCESS;
83 CAIRO_TEST (caps_joins_alpha,
84 "Test caps and joins with some source alpha",
85 "stroke", /* keywords */
86 NULL, /* requirements */
87 3 * (PAD + SIZE) + PAD,