POLYBEZIERTO, POLYBEZIERTO_W (W*32, W*64)

Graphics Functions: Draw one or more Bezier curves.

Module

USE IFQWIN

Syntax

result = POLYBEZIERTO (ppoints,cpoints)

result = POLYBEZIERTO_W (wppoints,cpoints)

ppoints

(Input) Derived type xycoord. Array of derived types defining the endpoints and the control points for each Bezier curve. The derived type xycoordis 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 ppoints or wppoints.

wppoints

(Input) Derived type wxycoord. Array of derived types defining the endpoints and the control points for each Bezier curve. The derived type wxycoordis defined in IFQWIN.F90 as follows: TYPE wxycoord
REAL(8) wx
REAL(8) wy

END TYPE wxycoord

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 is the current graphics position as set by MOVETO for the first curve; subsequent curves use the ending point of the previous curve as their starting point. So, cpoints should contain 3 for one curve, 6 for 2 curves, 9 for 3 curves, and so forth.

POLYBEZIERTO moves the current graphics position to the ending point of the last curve drawn.

Compatibility

STANDARD GRAPHICS QUICKWIN GRAPHICS LIB

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

See Also