2 * Copyright © 2005 Billy Biggs
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 * Billy Biggs not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Billy Biggs 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 * BILLY BIGGS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL BILLY BIGGS 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: Billy Biggs <vektor@dumbterm.net>
26 #include "cairo-test.h"
28 /* The star shape from the SVG test suite, from the fill rule test */
30 big_star_path (cairo_t *cr)
32 cairo_move_to (cr, 40, 0);
33 cairo_rel_line_to (cr, 25, 80);
34 cairo_rel_line_to (cr, -65, -50);
35 cairo_rel_line_to (cr, 80, 0);
36 cairo_rel_line_to (cr, -65, 50);
37 cairo_close_path (cr);
40 static cairo_test_status_t
41 draw (cairo_t *cr, int width, int height)
45 cairo_set_source_rgb (cr, 0, 0, 0);
48 cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
51 cairo_arc (cr, 40, 40, 20, 0, 2 * M_PI);
52 cairo_set_source_rgb (cr, 1, 0, 0);
55 /* Try using clipping to draw a circle */
56 cairo_arc (cr, 100, 40, 20, 0, 2 * M_PI);
58 cairo_rectangle (cr, 80, 20, 40, 40);
59 cairo_set_source_rgb (cr, 0, 0, 1);
62 /* Reset the clipping */
63 cairo_reset_clip (cr);
65 /* Draw a bunch of lines */
66 cairo_set_line_width (cr, 1.0);
67 cairo_set_source_rgb (cr, 0, 1, 0);
68 for (i = 0; i < 10; i++) {
69 cairo_move_to (cr, 10, 70 + (i * 4));
70 cairo_line_to (cr, 120, 70 + (i * 18));
74 /* Try filling a poly */
75 cairo_translate (cr, 160, 120);
76 cairo_set_source_rgb (cr, 1, 1, 0);
78 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
80 cairo_translate (cr, -160, -120);
82 /* How about some curves? */
83 cairo_set_source_rgb (cr, 1, 0, 1);
84 for (i = 0; i < 10; i++) {
85 cairo_move_to (cr, 150, 50 + (i * 5));
86 cairo_curve_to (cr, 250, 50, 200, (i * 10), 300, 50 + (i * 10));
90 return CAIRO_TEST_SUCCESS;
93 CAIRO_TEST (unantialiased_shapes,
94 "Test shape drawing without antialiasing",
95 "fill, stroke", /* keywords */
96 "target=raster", /* requirements */