[test] Add test case for a leaky dashed rectangle.
[cairo/haiku.git] / test / svg-surface.c
blob99b7b4ea01e75d653260c9d2ed7bbc19c6cbc87c
1 /*
2 * Copyright © 2005 Red Hat, Inc.
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 * Red Hat, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Red Hat, Inc. 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 * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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: Carl D. Worth <cworth@cworth.org>
26 #include <stdio.h>
28 #include <cairo-svg.h>
29 #include "cairo-test.h"
31 /* Pretty boring test just to make sure things aren't crashing ---
32 * no verification that we're getting good results yet.
33 * But you can manually view the image to make sure it looks happy.
36 #define WIDTH_IN_INCHES 3
37 #define HEIGHT_IN_INCHES 3
38 #define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72)
39 #define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72)
41 static cairo_test_status_t
42 draw (cairo_t *cr, int width, int height)
44 #define STROKE_WIDTH .04
46 double size;
48 if (width > height)
49 size = height;
50 else
51 size = width;
53 cairo_translate (cr, (width - size) / 2.0, (height - size) / 2.0);
54 cairo_scale (cr, size, size);
56 /* Fill face */
57 cairo_arc (cr, 0.5, 0.5, 0.5 - STROKE_WIDTH, 0, 2 * M_PI);
58 cairo_set_source_rgb (cr, 1, 1, 0);
59 cairo_save (cr);
61 cairo_fill (cr);
63 cairo_restore (cr);
65 cairo_set_source_rgb (cr, 0, 0, 0);
67 /* Stroke face */
68 cairo_set_line_width (cr, STROKE_WIDTH / 2.0);
69 cairo_stroke (cr);
71 /* Eyes */
72 cairo_set_line_width (cr, STROKE_WIDTH);
73 cairo_arc (cr, 0.3, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
74 cairo_fill (cr);
75 cairo_arc (cr, 0.7, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
76 cairo_fill (cr);
78 /* Mouth */
79 cairo_move_to (cr, 0.3, 0.7);
80 cairo_curve_to (cr,
81 0.4, 0.8,
82 0.6, 0.8,
83 0.7, 0.7);
84 cairo_stroke (cr);
86 return CAIRO_TEST_SUCCESS;
89 int
90 main (void)
92 cairo_t *cr;
93 const char *filename = "svg-surface.svg";
94 cairo_surface_t *surface;
96 cairo_test_init ("svg-surface");
98 surface = cairo_svg_surface_create (filename,
99 WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
100 if (surface == NULL) {
101 fprintf (stderr, "Failed to create svg surface for file %s\n", filename);
102 return CAIRO_TEST_FAILURE;
105 cr = cairo_create (surface);
107 draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
109 cairo_show_page (cr);
111 cairo_destroy (cr);
112 cairo_surface_destroy (surface);
114 printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
116 cairo_test_fini ();
118 return 0;