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->setSourceRgb ( 1, 1, 1);
13 $surface_size / 2, $surface_size / 2);
15 $con2->setSourceRgb ( 1, 0, 0);
18 $surface_size / 2, $surface_size / 2);
20 $con2->setSourceRgb ( 0, 1, 0);
23 $surface_size / 2, $surface_size / 2);
25 $con2->setSourceRgb ( 0, 0, 1);
27 $surface_size / 2, $surface_size / 2,
28 $surface_size / 2, $surface_size / 2);
32 /* First paint opaque background (black) so we don't need separate
33 * ARGB32 and RGB24 reference images. */
34 $con->setSourceRgb ( 0, 0, 0); /* black */
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->setSourceSurface ( $s, 0, 0);
42 $pat = $con->getSource();
44 $pat->setFilter(FILTER_NEAREST
);
45 $con->setSource($pat);
47 $sur->writeToPng("rotate-image-surface-paint-php.png");