program dislin_color3d;

uses
   dislin;

const
   n	= 50;
   m	= 50;
   nlev	=  20;
   
var
   i, j		   : int32;
   fpi, step, stepx, stepy, x, y : double;
   zmat		   : array[0..n*m-1] of double;
   xray		   : array[0..n-1] of double;
   yray		   : array[0..m-1] of double;
   zlev		   : array[0..nlev-1] of double;
   ctit1	   : ansistring = 'Shaded Surface / Contour Plot';
   ctit2	   : ansistring = 'F(X,Y) = 2*SIN(X)*SIN(Y)';

begin
   stepx := 360.0 / (n - 1);
   stepy := 360.0 / (m - 1);
   fpi := 3.1415926 / 180.0;

   for i:= 1 to n  do
   begin
      x := (i - 1) * stepx;
      xray[i-1] := x;
      for j:= 1 to m do
      begin	 
	 y := (j - 1) * stepy;
	 yray[j] := y;
	 zmat[i - 1 + (j - 1) * m] := 2 * sin (x * fpi) * sin (y * fpi);
      end;
   end;

   scrmod ('revers');
   setpag ('da4p');
   metafl ('cons');
   disini ();
   pagera ();
   hwfont ();
   axspos (200, 2600);
   axslen (1800, 1800);

   name   ('X-axis', 'x');
   name   ('Y-axis', 'y');
   name   ('Z-axis', 'z');

   titlin (ctit1, 2);
   titlin (ctit2, 4);

   graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
             -2.0, 2.0, -2.0, 1.0);
   height (50);
   title  ();

   grfini (-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0);
   nograf ();
   graf   (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0);
   step := 4.0 / nlev;
   for i:= 0 to nlev - 1 do
      zlev[i] := -2.0 + i * step; 

   conshd (@xray[0], n, @yray[0], n, @zmat[0], @zlev[0], nlev);
   box2d  ();
   reset  ('nograf');
   grffin ();

   shdmod ('smooth', 'surface'); 
   surshd (@xray[0], n, @yray[0], n, @zmat[0]);
   disfin ();
end.
