home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / maths / pgplot_1 / Examples / f77 / PGDEMO11 < prev    next >
Text File  |  1997-06-10  |  3KB  |  103 lines

  1.       PROGRAM PGDE11
  2. C-----------------------------------------------------------------------
  3. C Demonstration program for PGPLOT: travelling sine wave.
  4. C
  5. C This program illustrates how animated displays can be generated with
  6. C PGPLOT, although PGPLOT is not optimized for such use.
  7. C
  8. C To create an animated display:
  9. C
  10. C  (1) Do not call PGPAGE (or PGENV, which calls PGPAGE) between frames;
  11. C  (2) Enclose all the calls required to generate each frame between
  12. C      PGBBUF and PGEBUF calls;
  13. C  (3) Either: erase the entire previous frame by calling PGERAS before
  14. C      drawing the next frame; or: erase the parts of the frame that
  15. C      have changed by overwriting with the background color (color
  16. C      index 0).
  17. C
  18. C This program demonstrated both approaches. Using PGERAS is usually
  19. C slower, because more has to be redrawn in each frame. Erasing selected
  20. C parts of the display can be faster, but it may be difficult to avoid
  21. C erasing parts that should remain visible.
  22. C
  23. C This program requires an interactive display that supports writing
  24. C in color index 0.
  25. C-----------------------------------------------------------------------
  26. C Parameters:
  27. C   NT is the number of frames in the animation.
  28.       INTEGER N,NT
  29.       REAL PI,A,B
  30.       PARAMETER (N = 50)
  31.       PARAMETER (NT = 100)
  32.       PARAMETER (PI=3.14159265359)
  33.       PARAMETER (A = 2.0*PI/N)
  34.       PARAMETER (B = 2.0*PI/NT)
  35. C Variables:
  36.       REAL X(0:N), Y(0:N)
  37.       INTEGER I, T, L
  38.       CHARACTER*8 STR
  39.       INTEGER PGBEG
  40. C-----------------------------------------------------------------------
  41.  
  42.       WRITE (*,*) 'Demonstration of animation with PGPLOT'
  43.       WRITE (*,*) 'This program requires an interactive display that'
  44.       WRITE (*,*) 'supports writing in color index 0.'
  45.  
  46.       IF (PGBEG(0,'?',1,1) .NE. 1) STOP
  47.  
  48.       CALL PGQINF('HARDCOPY', STR, L)
  49.       IF (STR(:L).NE.'NO') WRITE (*,*)
  50.      :     'Warning: device is not interactive'
  51.  
  52.       WRITE (*,*) '1: erasing the entire screen between frames'
  53.  
  54.       CALL PGPAGE
  55.       CALL PGVSTD
  56.       CALL PGWNAD(-A, A*(N+1), -1.1, 1.1)
  57.       
  58.       DO 200 T=0,NT
  59.         CALL PGBBUF
  60.         CALL PGERAS
  61.         CALL PGSCI(1)
  62.         CALL PGBOX('bcnst', 0.0, 0, 'bcnst', 0.0, 0)
  63.         DO 100 I=0,N
  64.           X(I) = I*A 
  65.           Y(I) = SIN(I*A-T*B)  
  66.   100   CONTINUE
  67.         CALL PGSCI(3)
  68.         CALL PGLINE(N+1,X,Y)
  69.         WRITE (STR,'(I8)') T
  70.         CALL PGMTXT('T', 2.0, 0.0, 0.0, STR)
  71.         CALL PGEBUF
  72.   200 CONTINUE
  73.  
  74.       CALL PGPAGE
  75.       WRITE (*,*) '2: erasing only the line between frames'
  76.  
  77.       CALL PGVSTD
  78.       CALL PGWNAD(-A, A*(N+1), -1.1, 1.1)
  79.       CALL PGBBUF
  80.       CALL PGSCI(1)
  81.       CALL PGBOX('bcnst', 0.0, 0, 'bcnst', 0.0, 0)
  82.       DO 300 I=0,N
  83.          X(I) = I*A 
  84.          Y(I) = SIN(I*A)  
  85.  300  CONTINUE
  86.       CALL PGEBUF
  87.    
  88.       DO 500 T=0,NT
  89.         CALL PGBBUF
  90.         CALL PGSCI(0)
  91.         CALL PGLINE(N+1,X,Y)
  92.         CALL PGSCI(3)
  93.         DO 400 I=0,N
  94.           X(I) = I*A 
  95.           Y(I) = SIN(I*A-T*B)  
  96.   400   CONTINUE
  97.         CALL PGLINE(N+1,X,Y)
  98.         CALL PGEBUF
  99.   500 CONTINUE
  100.  
  101.       CALL PGEND
  102.       END
  103.