home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / zsys / znode-12 / i / plot33.lbr / TEST.PZS / TEST.PAS
Encoding:
Pascal/Delphi Source File  |  1993-06-12  |  2.4 KB  |  87 lines

  1.  
  2. {************************************************************************
  3.  *                                                                      *
  4.  *                          PLOT Test Program                           *
  5.  *                                                                      *
  6.  ************************************************************************}
  7.  
  8. PROGRAM main;
  9. VAR
  10.     x,y: ARRAY [1..20] of REAL;
  11.     a,x1,y1,x2,y2,yf: REAL;
  12.     i,j,n: INTEGER;
  13.  
  14. {$I GRAF1.PAS}
  15. {$I GRAF2.PAS}
  16.  
  17. BEGIN
  18.     grinit ('test.vec   ');
  19.  
  20.     {        Plot Polygon           }
  21.     n := 20;                         
  22.  
  23.     FOR i := 1 to n DO BEGIN              { set up corner coord. }
  24.         a := 6.28318 * i / n;
  25.         x[i] := cos(a)*0.49 + 0.5;
  26.         y[i] := sin(a)*0.49 + 0.5;
  27.     END;
  28.  
  29.     Writeln(CON, 'Plotting ',n,' sided polygon');
  30.  
  31.     FOR i := 1 to n DO BEGIN                  { connect corners }
  32.         FOR j := i+1 to n DO segmnt( x[i],y[i], x[j],y[j] );
  33.     END;
  34.  
  35.     gprint;                                { advance to new frame }
  36.     color(0);
  37.     erase;
  38.     color(127);
  39.  
  40.     writecmd('T',1);                       {use Text cmd to advance page}
  41.     FOR I := 1 TO 18 DO writecmd( Chr(10),1 );
  42.     writecmd( Chr(0),1 );
  43.  
  44.     {            Plot Sine Curve Graph               }
  45.  
  46.     Writeln(CON, 'Plotting sine curve figure');
  47.  
  48.     Writeln(CON, '    Drawing axes and grid');
  49.     chset( 0.0292, 0.0279, 0.0 );
  50.     graph( 0.0,10.0,5, -1.0,1.0,6, 0.15,0.85,0.1,0.9 );
  51.  
  52.     Writeln(CON, '    Drawing outline curve');
  53.     point ( sx(0.0), sy(0.0) );
  54.  
  55.     a := 0.2;
  56.     WHILE a<=10.0 DO BEGIN         { draw outline }
  57.         x1 := a;
  58.         y1 := exp( -a/5.0 ) * sin(a);
  59.  
  60.         vector( sx(x1), sy(y1) );
  61.         a := a + 0.2
  62.     END;
  63.  
  64.     Writeln(CON, '    Filling area under curve');
  65.     yf := sy(0.0);
  66.     x1 := sx(0.0);
  67.     y1 := sy(0.0);
  68.  
  69.     color(96);
  70.  
  71.     a := 0.2;
  72.     WHILE a<=10.0 DO BEGIN          { fill in outline }
  73.         x2 := sx(a);
  74.         y2 := sy( exp( -a/5.0 ) * sin(a) );
  75.         fill ( x1,y1, x2,y2, yf);
  76.         x1 := x2;
  77.         y1 := y2;
  78.         a := a + 0.2
  79.     END;
  80.  
  81.     Writeln(CON, '    Printing title');
  82.     gstrng( 0.425, 0.95,'Sine Curve Test Plot');
  83.  
  84.     Writeln(CON, 'Finished Plotting');
  85.     grfini;
  86. END.
  87.