home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / plot33 / plot33.lbr / TEST.PQS / TEST.PAS
Encoding:
Pascal/Delphi Source File  |  1985-02-10  |  2.4 KB  |  86 lines

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