Typo ;)
[phpCairo.git] / testcases / phpCairo / line-width-scale.php
blobf34df0d0316090676670eca6345b9505139b96a1
1 <?
2 function spline_path ()
4 global $spline,$con;
5 $con->save ();
7 $con->move_to (
8 - $spline, 0);
9 $con->curve_to (
10 - $spline / 4, - $spline,
11 $spline / 4, $spline,
12 $spline, 0);
14 $con->restore ();
17 function scale_then_set_line_width_and_stroke ()
19 global $con,$xscale,$yscale,$linewidth;
20 $con->scale ( $xscale, $yscale);
21 $con->set_line_width ( $linewidth);
22 spline_path ();
23 $con->stroke ();
26 function scale_path_and_line_width ()
28 global $con, $xscale, $yscale,$linewidth;
29 $con->save ();
31 $con->scale ( $xscale, $yscale);
32 spline_path ();
34 $con->restore ();
36 $con->save ();
38 $con->scale ( $xscale, $yscale);
39 $con->set_line_width ( $linewidth);
40 $con->stroke ();
42 $con->restore ();
45 function set_line_width_then_scale_and_stroke()
47 global $con, $xscale, $yscale,$linewidth;
48 $con->set_line_width ( $linewidth);
49 $con->scale ( $xscale, $yscale);
50 spline_path ();
51 $con->stroke ();
54 function scale_path_not_line_width ()
56 global $con, $xscale, $yscale,$linewidth;
58 $con->save ();
60 $con->scale ( $xscale, $yscale);
61 spline_path ();
63 $con->restore ();
65 $con->save ();
67 $con->set_line_width ( $linewidth);
68 $con->stroke ();
70 $con->restore ();
73 $linewidth = 13;
74 $spline = 50.0;
75 $xscale = 0.5;
76 $yscale = 2.0;
77 $width = ($xscale * $spline * 6.0);
78 $height = ($yscale * $spline * 2.0);
79 $sur = new CairoImageSurface(FORMAT_ARGB32, $width, $height);
80 $con = new CairoContext($sur);
81 $con->set_source_rgb ( 1.0, 1.0, 1.0); /* white */
82 $con->paint ();
83 $con->set_source_rgb ( 0.0, 0.0, 0.0); /* black */
84 for($i =0 ; $i<4;$i++) {
85 $con->save();
86 // $con->translate($width/4 + ($i % 2)*$width/2, $height/4 + ($i/2)*$height/2);
87 switch($i) {
88 case 0:
89 $con->translate($width/4 , $height/4);
90 scale_then_set_line_width_and_stroke();
91 break;
92 case 1:
93 $con->translate($width/4 + $width/2, $height/4);
94 scale_path_and_line_width();
95 break;
96 case 2:
97 $con->translate($width/4, $height/4 + $height/2);
98 set_line_width_then_scale_and_stroke();
99 break;
100 case 3:
101 $con->translate($width/4 + $width/2, $height/4 + $height/2);
102 scale_path_not_line_width();
103 break;
105 $con->restore();
107 $sur->write_to_png("line-width-scale-php.png");