Using Intel® Visual Fortran to Create and Build Windows*-Based Applications
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: GUID-995030B6-C921-41E4-8E9B-287591B76BDE
Visible to Intel only — GUID: GUID-995030B6-C921-41E4-8E9B-287591B76BDE
Drawing a Sine Curve
With the axes and frame in place, Writing a Graphics Program Overview 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 IFQWIN 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).