Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

POLYBEZIER, POLYBEZIER_W

Graphics Functions: Draw one or more Bezier curves. These routines are only available for Windows.

Module

USE IFQWIN

result = POLYBEZIER (lppoints,cpoints)

result = POLYBEZIER_W (lppoints,cpoints)

lppoints

(Input) Derived type xycoord. Array of derived types defining the endpoints and the control points for each Bezier curve. The derived type xycoord is defined in IFQWIN.F90 as follows:

 TYPE xycoord
   INTEGER(2) xcoord
   INTEGER(2) ycoord
 END TYPE xycoord

cpoints

(Input) INTEGER(2). Number of points in lppoints.

Results

The result type is INTEGER(2). The result is nonzero if anything is drawn; otherwise, 0.

A Bezier curve is based on fitting a cubic curve to four points. The first point is the starting point, the next two points are control points, and last point is the ending point. The starting point must be given for the first curve; subsequent curves use the ending point of the previous curve as their starting point. So, cpoints should contain 4 for one curve, 7 for 2 curves, 10 for 3 curves, and so forth.

POLYBEZIER does not use or change the current graphics position.

Example

Program Bezier
use IFQWIN
! Shows how to use POLYBEZIER, POLYBEZIER_W,
! POLYBEZIERTO, and POLYBEZIERTO_W,
TYPE(xycoord)  lppoints(31)
TYPE(wxycoord) wlppoints(31)
TYPE(xycoord)  xy
TYPE(wxycoord) wxy
integer(4) i
integer(2) istat, orgx, orgy
real(8) worgx, worgy
i = setcolorrgb(Z'00FFFFFF') ! graphic to black
i = settextcolorrgb(Z'00FFFFFF') ! text to black
i = setbkcolorrgb(Z'00000000') ! background to white
call clearscreen($GCLEARSCREEN)
orgx = 20
orgy = 20
lppoints(1)%xcoord = 1+orgx
lppoints(1)%ycoord = 1+orgy
lppoints(2)%xcoord = 30+orgx
lppoints(2)%ycoord = 120+orgy
lppoints(3)%xcoord = 150+orgx
lppoints(3)%ycoord = 60+orgy
lppoints(4)%xcoord = 180+orgx
lppoints(4)%ycoord = 180+orgy
istat = PolyBezier(lppoints, 4)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point.   It is also tangent to the line from
! the second control point to the end point.
do i = 1,4,2
call moveto(lppoints(i)%xcoord,lppoints(i)%ycoord,xy)
istat = lineto(lppoints(i+1)%xcoord,lppoints(i+1)%ycoord)
end do
read(*,*)
worgx = 50.0
worgy = 50.0
wlppoints(1)%wx = 1.0+worgx
wlppoints(1)%wy = 1.0+worgy
wlppoints(2)%wx = 30.0+worgx
wlppoints(2)%wy = 120.0+worgy
wlppoints(3)%wx = 150.0+worgx
wlppoints(3)%wy = 60.0+worgy
wlppoints(4)%wx = 180.0+worgx
wlppoints(4)%wy = 180.0+worgy
i = setcolorrgb(Z'000000FF') ! graphic to red
istat = PolyBezier_W(wlppoints, 4)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point.   It is also tangent to the line from
! the second control point to the end point.
do i = 1,4,2
call moveto_w(wlppoints(i)%wx,wlppoints(i)%wy,wxy)
istat = lineto_w(wlppoints(i+1)%wx,wlppoints(i+1)%wy)
end do
read(*,*)
orgx = 80
orgy = 80
! POLYBEZIERTO uses the current graphics position
! as its initial starting point so we start the
! array with the first first control point.
! lppoints(1)%xcoord = 1+orgx ! need to move to this
! lppoints(1)%ycoord = 1+orgy
lppoints(1)%xcoord = 30+orgx
lppoints(1)%ycoord = 120+orgy
lppoints(2)%xcoord = 150+orgx
lppoints(2)%ycoord = 60+orgy
lppoints(3)%xcoord = 180+orgx
lppoints(3)%ycoord = 180+orgy
i = setcolorrgb(Z'0000FF00') ! graphic to green
call moveto(1+orgx,1+orgy,xy)
istat = PolyBezierTo(lppoints, 3)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point.   It is also tangent to the line from
! the second control point to the end point.
call moveto(1+orgx,1+orgy,xy)
istat = lineto(lppoints(1)%xcoord,lppoints(1)%ycoord)
call moveto(lppoints(2)%xcoord,lppoints(2)%ycoord,xy)
istat = lineto(lppoints(3)%xcoord,lppoints(3)%ycoord)
read(*,*)
worgx = 110.0
worgy = 110.0
!wlppoints(1)%wx = 1.0+worgx
!wlppoints(1)%wy = 1.0+worgy
wlppoints(1)%wx = 30.0+worgx
wlppoints(1)%wy = 120.0+worgy
wlppoints(2)%wx = 150.0+worgx
wlppoints(2)%wy = 60.0+worgy
wlppoints(3)%wx = 180.0+worgx
wlppoints(3)%wy = 180.0+worgy
call moveto_w(1.0+worgx,1.0+worgy,wxy)
i = setcolorrgb(Z'00FF0000') ! graphic to blue
istat = PolyBezierTo_W(wlppoints, 3)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point.   It is also tangent to the line from
! the second control point to the end point.
call moveto_w(1.0+worgx,1.0+worgy,wxy)
istat = lineto_w(wlppoints(1)%wx,wlppoints(1)%wy)
call moveto_w(wlppoints(2)%wx,wlppoints(2)%wy,wxy)
istat = lineto_w(wlppoints(3)%wx,wlppoints(3)%wy)
read(*,*)
END PROGRAM Bezier