Added some test cases ....
[phpCairo.git] / testcases / phpCairo / rotate-image-surface-paint.php
blobacacc85697e16a0975b7fa941e6e3f3514675a82
1 <?
2 $size = 20;
3 $pad = 2;
4 $surface_size = sqrt(($size - 2*$pad)*($size-2*$pad)/2);
5 $sur = new CairoImageSurface(FORMAT_ARGB32, $size, $size);
6 $con = new CairoContext($sur);
7 $s = new CairoImageSurface(FORMAT_RGB24,
8 $surface_size, $surface_size);
9 $con2 = new CairoContext($s);
10 $con2->set_source_rgb ( 1, 1, 1);
11 $con2->rectangle (
12 0, 0,
13 $surface_size / 2, $surface_size / 2);
14 $con2->fill ();
15 $con2->set_source_rgb ( 1, 0, 0);
16 $con2->rectangle (
17 $surface_size / 2, 0,
18 $surface_size / 2, $surface_size / 2);
19 $con2->fill ();
20 $con2->set_source_rgb ( 0, 1, 0);
21 $con2->rectangle (
22 0, $surface_size / 2,
23 $surface_size / 2, $surface_size / 2);
24 $con2->fill ();
25 $con2->set_source_rgb ( 0, 0, 1);
26 $con2->rectangle (
27 $surface_size / 2, $surface_size / 2,
28 $surface_size / 2, $surface_size / 2);
29 $con2->fill ();
32 /* First paint opaque background (black) so we don't need separate
33 * ARGB32 and RGB24 reference images. */
34 $con->set_source_rgb ( 0, 0, 0); /* black */
35 $con->paint ();
37 $con->translate( $size/2, $size/2);
38 $con->rotate ( M_PI / 4.0);
39 $con->translate ( -$surface_size/2, -$surface_size/2);
41 $con->set_source_surface ( $s, 0, 0);
42 $pat = $con->get_source();
44 $pat->set_filter(FILTER_NEAREST);
45 $con->set_source($pat);
46 $con->paint ();
47 $sur->write_to_png("rotate-image-surface-paint-php.png");