1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
use strict; use warnings;
use Test::More;
use Config;
# Stop f77-linking causing spurious undefined symbols (alpha)
$ENV{'PERL_DL_NONLAZY'}=0 if $Config{'osname'} eq "dec_osf";
require PGPLOT;
my $dev = $ENV{PGPLOT_DEV} || '/NULL';
$ENV{PGPLOT_XW_WIDTH}=0.3;
PGPLOT::pgbegin(0,$dev,2,2);
PGPLOT::pgsci(3); PGPLOT::pgscf(2); PGPLOT::pgsch(1.4);
my $pi=3.141592654;
# Anonymous subs!
PGPLOT::pgfunx(sub{ sqrt($_[0]) }, 500, 0, 10, 0);
PGPLOT::pgfuny(sub{ sin(4*$_[0]) }, 360, 0, 2*$pi, 0);
# Pass by name and pass by reference
PGPLOT::pgfunt("funt_x", "funt_y", 360,0, 2*$pi, 0);
PGPLOT::pgfunt(\&funt_x2, \&funt_y2, 360,0, 2*$pi, 0);
PGPLOT::pgend();
pass;
done_testing;
sub funt_x {
my($t)=$_[0];
return cos($t);;
}
sub funt_y {
my($t)=$_[0];
return sin($t);
}
sub funt_x2 {
my($t)=$_[0];
return cos(4*$t)*cos($t);;
}
sub funt_y2 {
my($t)=$_[0];
return cos(4*$t)*sin($t);
}
|