Presenting Mathematical Concepts on the World Wide Web
Forms & Scripts
Using Scripts: Axes Demo Source Code
#!/usr/local/bin/perl
require "/u/www/root/admin/bin/cgi.pl";
require "axes.pl";
#make sure to include paths to programs invoked
$ENV{"PATH"} .= ":/usr/local/bin:/u/share/bin";
print &mime_header();
%data = &get_data();
$x = $data{"x"};
$y = $data{"y"};
$xmax = $data{"xmax"};
$ymax = $data{"ymax"};
&gifsize(20, 380, 280, 20, $x, $y);
&pssize( 20, 380, 20, 280);
&sizetofit($xmax, $ymax);
$file = "tmp/$$";
$psfile = $file.".eps";
$giffile = $file.".gif";
open(TMP,">> $psfile"); # $$ returns PID in Perl
print TMP
"%%BoundingBox: 0 0 450 450
newpath
.1 setlinewidth
0 0 moveto 400 0 lineto 400 300 lineto 0 300 lineto closepath stroke
1 setlinewidth
";
($amin_x, $amin_y) = &u2p($umin_x, $umin_y);
($amax_x, $amax_y) = &u2p($umax_x, $umax_y);
($ax,$ay) = &g2p($x,$y);
print TMP
"newpath
$amin_x $ay moveto $amax_x $ay lineto stroke
newpath
$ax $amin_y moveto $ax $amax_y lineto stroke";
&xticks();
&yticks();
close(TMP); #important
system("convert $psfile $giffile");
print "
<HTML><HEAD><TITLE>Axes Demo</TITLE></HEAD>
<BODY>
<FORM ACTION=\"axesdemo.cgi\">
<INPUT TYPE=image SRC=$giffile><P>
x max: <INPUT SIZE=3 NAME=xmax value=$xmax><BR>
y max: <INPUT SIZE=3 NAME=ymax value=$ymax>
</FORM>
<HR>
</BODY>
</HTML>";
Back: Strategies for Using Scripts
Up:
Forms & Scripts
Presenting Mathematical Concepts on the World Wide Web.
Copyright © 1997 by
Carol Scheftic.
All rights reserved.
(This section was originally copyrighted in 1996 by
The Geometry Center
and is re-used here with permission.)
Please send comments on this page,
or requests for permission to re-use material from this page, to:
scheftic@geom.umn.edu
Page established 1-Jun-97;
last updated Thursday, 24-Jul-1997 01:51:31 CDT.