1
/*
2
 * Permission is hereby granted, free of charge, to any person
3
 * obtaining a copy of this software and associated documentation
4
 * files (the "Software"), to deal in the Software without
5
 * restriction, including without limitation the rights to use, copy,
6
 * modify, merge, publish, distribute, sublicense, and/or sell copies
7
 * of the Software, and to permit persons to whom the Software is
8
 * furnished to do so, subject to the following conditions:
9
 *
10
 * The above copyright notice and this permission notice shall be
11
 * included in all copies or substantial portions of the Software.
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
17
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
 * SOFTWARE.
21
 *
22
 * Author: Krzysztof Kosi\u0144ski <tweenk.pl@gmail.com>
23
 */
24

            
25
/* Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40918 */
26

            
27
#include "cairo-test.h"
28

            
29
static cairo_test_status_t
30
3
draw (cairo_t *cr, int width, int height)
31
{
32
    cairo_pattern_t *radial;
33
    double angle;
34
    int i, j;
35

            
36
3
    cairo_set_source_rgb (cr, 0, 0, 1);
37
3
    cairo_paint (cr);
38

            
39
3
    angle = 0.0;
40

            
41
15
    for (i = 0; i < 4; i++) {
42
60
	for (j = 0; j < 4; j++) {
43
48
	    cairo_save (cr);
44
48
	    cairo_rectangle (cr, 100*i, 100*j, 100, 100);
45
48
	    cairo_clip (cr);
46

            
47
48
	    radial = cairo_pattern_create_radial (cos (angle), sin (angle), 0,
48
						  0, 0, 1);
49
48
	    cairo_pattern_add_color_stop_rgb (radial, 0.0, 1, 0, 0);
50
48
	    cairo_pattern_add_color_stop_rgb (radial, 1.0, 0, 1, 0);
51

            
52
48
	    cairo_translate (cr, 100*i+50, 100*j+50);
53
48
	    cairo_scale (cr, 50, -50);
54
48
	    cairo_set_source (cr, radial);
55
48
	    cairo_pattern_destroy (radial);
56

            
57
48
	    cairo_paint(cr);
58
48
	    cairo_restore (cr);
59

            
60
48
	    angle += M_PI/17;
61
	}
62
    }
63

            
64
3
    return CAIRO_TEST_SUCCESS;
65
}
66

            
67
1
CAIRO_TEST (radial_outer_focus,
68
	    "Exercises the condition of rendering a radial gradial on its outer focus",
69
	    "radial", /* keywords */
70
	    NULL, /* requirements */
71
	    400, 400,
72
	    NULL, draw)