BCX_POLYBEZIER function

Purpose: BCX_POLYBEZIER function draws one or more Bézier curves.


 Syntax:

 RetVal% = BCX_POLYBEZIER(hWnd, _
                        pPoints, _
                     numPoints%  _
                         [, Pen] _
                     [, DrawHDC])

 Parameters:

  • RetVal% Nonzero integer if the function succeeds, zero if the function fails.
  • hWnd Identifies the window where drawing takes place.
  • pPoints Pointer to an array of POINT structures that contain the endpoints and control points of the curve(s).
  • numPoints% Specifies the number of points in the pPoints array. This value must be one more than three times the number of curves to be drawn, because each Bézier curve requires two control points and an endpoint, and the initial curve requires an additional starting point.
  • Pen [OPTIONAL] integer representing the RGB color code. The default is 0 which is a black pen.
  • DrawHDC [OPTIONAL] HDC(Handle to Device Context) pointing to an already open HDC. This is useful if a device context is to be written to many times. In this case the programmer is responsible for closing the HDC at the appropriate time.

Here is an example of the BCX_POLYBEZIER function.


 GUI "BCX_POLYBEZIER"

 DIM pPoints[10] AS POINT

 SUB FORMLOAD
 GLOBAL Form1 AS HWND
 DIM i%
 DIM pi2#
 pi2# = 8 * ATN(1.)
 FOR i = 0 TO 9
    pPoints[i%].x = 110 + SIN(pi2#*i/10) * 10 * i
    pPoints[i%].y = 110 + COS(pi2#*i/10) * 10 * i
 NEXT
 Form1 = BCX_FORM("BCX_POLYBEZIER", 0, 0, 110, 110)
 BCX_SET_FORM_COLOR(Form1,QBCOLOR(31))
 CENTER(Form1)
 SHOW(Form1)
 END SUB

 BEGIN EVENTS
 SELECT CASE CBMSG
    CASE WM_PAINT
    CALL DrawStuff

    CASE WM_CLOSE
    DestroyWindow(Form1)
    EXIT FUNCTION
 END SELECT
 END EVENTS


 SUB DrawStuff
 DIM RAW RetVal%
 RetVal% = BCX_POLYBEZIER(Form1, pPoints, 10, QBCOLOR(4))
 END SUB