1 /* cc `pkg-config --cflags --libs cairo` cairo-spline-image.c -o cairo-spline-image */
3 /* Copyright © 2005 Carl Worth
4 * Copyright © 2012 Intel Corporation
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use, copy,
10 * modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 #include "cairo-test.h"
29 #define WIDE_LINE_WIDTH 160
30 #define NARROW_LINE_WIDTH 2
32 /* A spline showing bugs in the "contour-based stroking" in cairo 1.12 */
33 static const struct spline {
34 struct { double x, y; } pt[5];
59 #define NUM_SPLINES (sizeof(splines)/sizeof(splines[0]))
61 static cairo_test_status_t
62 draw (cairo_t *cr, int width, int height)
66 cairo_set_source_rgb (cr, 0, 0, 0);
69 cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
71 for (n = 0; n < NUM_SPLINES; n++) {
72 cairo_set_line_width (cr, splines[n].line_width);
73 cairo_set_source_rgba (cr,
79 cairo_move_to (cr, splines[n].pt[0].x, splines[n].pt[0].y);
81 splines[n].pt[1].x, splines[n].pt[1].y,
82 splines[n].pt[2].x, splines[n].pt[2].y,
83 splines[n].pt[3].x, splines[n].pt[3].y);
88 return CAIRO_TEST_SUCCESS;
91 CAIRO_TEST (bug_spline,
92 "Exercises a bug in the stroking of splines",
93 "spline, stroke", /* keywords */
94 NULL, /* requirements */