| 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 |
$SIZE=100.0; |
| 12 |
$EXPAND = 2.2; |
| 13 |
$M_PI= 3.14159265358979; |
| 14 |
# /* set a Plotter parameter */ |
| 15 |
pl_parampl("PAGESIZE", "letter"); |
| 16 |
# /* create a Postscript Plotter that writes to standard output */ |
| 17 |
pl_parampl ("BITMAPSIZE", "500x500"); |
| 18 |
if (($handle = pl_newpl ($device, stdin, stdout, stderr)) < 0) |
| 19 |
{ |
| 20 |
die "Couldn't create Plotter"; |
| 21 |
} |
| 22 |
pl_selectpl ($handle); # /* select the Plotter for use */ |
| 23 |
|
| 24 |
if (pl_openpl () < 0) # /* open Plotter */ |
| 25 |
{ |
| 26 |
die "Couldn't open Plotter"; |
| 27 |
} |
| 28 |
pl_fspace (-($SIZE), -($SIZE), $SIZE, $SIZE); #/* specify user coor system */ |
| 29 |
pl_pencolorname ("blue"); # /* pen color will be blue */ |
| 30 |
pl_fillcolorname ("white"); |
| 31 |
pl_filltype (1); # /* ellipses will be filled with white */ |
| 32 |
# fontname ("NewCenturySchlbk-Roman");# /* choose a Postscript font */ |
| 33 |
# fontname ("utopia-medium-r-normal");# /* choose a Postscript font */ |
| 34 |
pl_fontname ("HersheySerif");# /* choose a Postscript font */ |
| 35 |
{ |
| 36 |
my $i; |
| 37 |
for ($i = 80; $i > 1; $i--) # /* loop through angles */ |
| 38 |
{ |
| 39 |
$theta = 0.5 * $i; # /* theta is in radians */ |
| 40 |
$radius = $SIZE / ($theta**(0.35)); #/* this yields a spiral */ |
| 41 |
pl_fmove($radius * cos($theta), $radius * sin($theta)); |
| 42 |
draw_boxed_string("GNU libplot!", 0.04 * $radius,(180.0*$theta / $M_PI) - 90.0); |
| 43 |
} |
| 44 |
} |
| 45 |
if (pl_closepl () < 0) # /* close Plotter */ |
| 46 |
{ |
| 47 |
die "Couldn't close Plotter"; |
| 48 |
} |
| 49 |
pl_selectpl (0); |
| 50 |
if (pl_deletepl ($handle) < 0) # /* delete Plotter we used */ |
| 51 |
{ |
| 52 |
die "Couldn't delete Plotter"; |
| 53 |
} |
| 54 |
|
| 55 |
sub draw_boxed_string |
| 56 |
{ |
| 57 |
my ($s,$size,$angle) = @_; |
| 58 |
my ($true_size,$width); |
| 59 |
pl_ftextangle($angle); #/* text inclination angle (degrees) */ |
| 60 |
$true_size = pl_ffontsize($size); #/* choose font size */ |
| 61 |
$width = pl_flabelwidth($s); #/* compute width of text string */ |
| 62 |
pl_fellipserel (0.0, 0.0, $EXPAND * 0.5 * $width, $EXPAND * 0.5 * $true_size, $angle); |
| 63 |
pl_alabel (ord 'c', ord 'c', $s); #/* draw centered text string */ |
| 64 |
} |
| 65 |
|
| 66 |
1; #OK |