Examples updated to the latest Camel Case .. Was a pain converting them
[phpCairo.git] / testcases / phpCairo / rectilinear-stroke.php
bloba472f976ff3c4b8a33d06b71383d674866558d4e
1 <?
2 $size = 25;
3 $sur = new CairoImageSurface(FORMAT_ARGB32, $size, $size);
4 $con = new CairoContext($sur);
5 /* Paint background white, then draw in black. */
6 $con->setSourceRgb (1.0, 1.0, 1.0); /* white */
7 $con->paint ();
8 $con->setSourceRgb (0.0, 0.0, 0.0); /* black */
10 $con->setLineWidth (1.0);
11 $con->translate (1, 1);
13 /* Draw everything first with square caps. */
14 $con->setLineCap (LINE_CAP_SQUARE);
16 /* Draw horizontal and vertical segments, each in both
17 * directions. */
18 $con->moveTo ( 4.5, 0.5);
19 $con->relLineTo ( 2.0, 0.0);
21 $con->moveTo (10.5, 4.5);
22 $con->relLineTo ( 0.0, 2.0);
24 $con->moveTo ( 6.5, 10.5);
25 $con->relLineTo (-2.0, 0.0);
27 $con->moveTo ( 0.5, 6.5);
28 $con->relLineTo ( 0.0, -2.0);
30 /* Draw right angle turns in four directions. */
31 $con->moveTo ( 0.5, 2.5);
32 $con->relLineTo ( 0.0, -2.0);
33 $con->relLineTo ( 2.0, 0.0);
35 $con->moveTo ( 8.5, 0.5);
36 $con->relLineTo ( 2.0, 0.0);
37 $con->relLineTo ( 0.0, 2.0);
39 $con->moveTo (10.5, 8.5);
40 $con->relLineTo ( 0.0, 2.0);
41 $con->relLineTo (-2.0, 0.0);
43 $con->moveTo ( 2.5, 10.5);
44 $con->relLineTo (-2.0, 0.0);
45 $con->relLineTo ( 0.0, -2.0);
47 /* Draw a closed-path rectangle */
48 $con->rectangle (0.5, 12.5, 10.0, 10.0);
50 $con->stroke ();
52 $con->translate (12, 0);
54 /* Now draw the same results, but with butt caps. */
55 $con->setLineCap (LINE_CAP_BUTT);
57 /* Draw horizontal and vertical segments, each in both
58 * directions. */
59 $con->moveTo ( 4.0, 0.5);
60 $con->relLineTo ( 3.0, 0.0);
62 $con->moveTo (10.5, 4.0);
63 $con->relLineTo ( 0.0, 3.0);
65 $con->moveTo ( 7.0, 10.5);
66 $con->relLineTo (-3.0, 0.0);
68 $con->moveTo ( 0.5, 7.0);
69 $con->relLineTo ( 0.0, -3.0);
71 /* Draw right angle turns in four directions. */
72 $con->moveTo ( 0.5, 3.0);
73 $con->relLineTo ( 0.0, -2.5);
74 $con->relLineTo ( 2.5, 0.0);
76 $con->moveTo ( 8.0, 0.5);
77 $con->relLineTo ( 2.5, 0.0);
78 $con->relLineTo ( 0.0, 2.5);
80 $con->moveTo (10.5, 8.0);
81 $con->relLineTo ( 0.0, 2.5);
82 $con->relLineTo (-2.5, 0.0);
84 $con->moveTo ( 3.0, 10.5);
85 $con->relLineTo (-2.5, 0.0);
86 $con->relLineTo ( 0.0, -2.5);
88 /* Draw a closed-path rectangle */
89 $con->rectangle (0.5, 12.5, 10.0, 10.0);
91 /* Draw a path that is rectilinear initially, but not completely */
92 /* We draw this out of the target window. The bug that caused this
93 * addition was leaks if part of the path was rectilinear but not
94 * completely */
95 $con->moveTo ( 3.0, 30.5);
96 $con->relLineTo (-2.5, 0.0);
97 $con->relLineTo (+2.5, +2.5);
99 $con->stroke ();
100 $sur->writeToPng("rectilinear-stroke-php.png");