Debian Codegraph @

examples/movingeye

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] =~ /^X$/;
9 }
10
11
12 pl_parampl ("VANISH_ON_DELETE", "yes");
13 pl_parampl ("USE_DOUBLE_BUFFERING", "yes");
14
15 if (($handle = pl_newpl ($device, stdin, stdout, stderr)) < 0)
16 {
17 die "Couldn't create Plotter";
18 }
19 pl_selectpl($handle); # /* select the Plotter for use */
20 if (pl_openpl() < 0) # /* open Plotter */
21 {
22 die "Couldn't open Plotter";
23 }
24 pl_space(0, 0, 299, 149); # /* specify user coordinate system */
25 pl_parampl ("BITMAPSIZE", "300x150");
26 # Note a bug in XFree86 requires that the bitmap spec comes after newpl().
27 pl_linewidth (8); # /* width of lines in user coordinates */
28 pl_filltype (1); # /* objects will be filled */
29 pl_bgcolorname ("saddle brown"); # /* background color for the window */
30 for ($j = 0; $j < 300; $j++)
31 {
32 pl_erase (); # /* erase window */
33 pl_pencolorname ("red"); # /* choose red pen, with cyan filling */
34 pl_fillcolorname ("cyan");
35 pl_ellipse ($i, 75, 35, 50, $i); # /* draw an ellipse */
36 pl_colorname ("black"); # /* choose black pen, with black filling */
37 pl_circle ($i, 75, 12); # /* draw a circle [the pupil] */
38 $i = ($i + 2) % 300; # /* shift rightwards */
39 }
40 if (pl_closepl () < 0) # /* close Plotter */
41 {
42 die "Couldn't close Plotter";
43 }
44 pl_selectpl (0); # /* select default Plotter */
45 if (pl_deletepl ($handle) < 0) # /* delete Plotter we used */
46 {
47 die "Couldn't delete Plotter";
48 }
49
50 1; #OK