1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | // $Id: canvasbezierex1.php,v 1.1 2002/10/05 21:04:28 aditus Exp $ |
---|
3 | require_once ('jpgraph/jpgraph.php'); |
---|
4 | require_once ('jpgraph/jpgraph_canvas.php'); |
---|
5 | require_once ('jpgraph/jpgraph_canvtools.php'); |
---|
6 | |
---|
7 | // Setup canvas graph |
---|
8 | $g = new CanvasGraph(400,300); |
---|
9 | $scale = new CanvasScale($g); |
---|
10 | $shape = new Shape($g,$scale); |
---|
11 | |
---|
12 | $g->title->Set('Bezier line with control points'); |
---|
13 | |
---|
14 | // Setup control point for bezier |
---|
15 | $p = array(3,6, |
---|
16 | 6,9, |
---|
17 | 5,3, |
---|
18 | 7,4); |
---|
19 | |
---|
20 | // Visualize control points |
---|
21 | $shape->SetColor('blue'); |
---|
22 | $shape->Line($p[0],$p[1],$p[2],$p[3]); |
---|
23 | $shape->FilledCircle($p[2],$p[3],-6); |
---|
24 | |
---|
25 | $shape->SetColor('red'); |
---|
26 | $shape->Line($p[4],$p[5],$p[6],$p[7]); |
---|
27 | $shape->FilledCircle($p[4],$p[5],-6); |
---|
28 | |
---|
29 | // Draw bezier |
---|
30 | $shape->SetColor('black'); |
---|
31 | $shape->Bezier($p); |
---|
32 | |
---|
33 | // Frame it with a square |
---|
34 | $shape->SetColor('navy'); |
---|
35 | $shape->Rectangle(0.5,2,9.5,9.5); |
---|
36 | |
---|
37 | // ... and stroke it |
---|
38 | $g->Stroke(); |
---|
39 | ?> |
---|
40 | |
---|