Debian Codegraph @

examples/ccurve

raw
1 #!/usr/bin/perl
2 use Graphics::Libplot ':ALL';
3
4 # type of plotting device
5 $device = 'X';
6 if (@ARGV) {
7 $device = $ARGV[0];
8 # die "Uknown device: $ARGV[0]" unless $ARGV[0] =~ /^ps|X|fig$/;
9 }
10
11 $MAXORDER =12;
12 sub draw_c_curve
13 {
14 my($dx,$dy,$order) = @_;
15 if ($order >= $MAXORDER)
16 {pl_fcontrel ($dx, $dy); }
17 else
18 {
19 draw_c_curve (0.5 * ($dx - $dy), 0.5 * ($dx + $dy), $order + 1);
20 draw_c_curve (0.5 * ($dx + $dy), 0.5 * ($dy - $dx), $order + 1);
21 }
22 }
23
24 $handle = pl_newpl($device, stdin, stdout, stderr);
25 pl_selectpl ($handle);
26 pl_openpl ();
27 pl_fspace (0.0, 0.0, 1000.0, 1000.0);
28 pl_flinewidth (0.25);
29 pl_pencolorname ("red");
30 pl_erase ();
31 pl_fmove (600.0, 300.0);
32 draw_c_curve (0.0, 400.0, 0);
33 pl_closepl () ;
34 pl_selectpl (0);
35 pl_deletepl ($handle);
36
37 1; #OK