Drawing a Sine Curve

With the axes and frame in place, SINE is ready to draw the sine curve. The sinewave routine calculates the x and y positions for two cycles and plots them on the screen:

  ! SINEWAVE - This subroutine calculates and plots a sine wave.
 
  SUBROUTINE sinewave( )
  
     USE DFLIB

     INTEGER(2)    dummy, newx, newy, locx, locy, i
     INTEGER(4)    color
     REAL          rad
     EXTERNAL      newx, newy

     PARAMETER    ( PI = 3.14159 )
  !
  !  Calculate each position and display it on the screen.
     color = #0000FF ! red
  !
     DO i = 0, 999, 3
        rad   = -SIN( PI * i / 250.0 )
        locx  = newx( i )
        locy  = newy( INT2( rad * 250.0 ) )
        dummy = SETPIXELRGB( locx, locy, color )
     END DO
  END SUBROUTINE

SETPIXELRGB takes the two location parameters, locx and locy, and sets the pixel at that position with the specified color value (red).