现已得到了一些点,但怎样用光滑的曲线把它们连接起来呢??

解决方案 »

  1.   

    Private Declare Function PolyBezier& Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long)
    说明 
    描绘一条或多条贝塞尔(Bezier)曲线。返回值 
    Long,非零表示成功,零表示失败 
    参数表 
    参数 类型及说明 
    hdc Long,要在其中绘图的设备场景 
    lppt POINTAPI,指定一个POINTAPI结构数组。其中的第一个结构指定了起点。剩下的点三个一组——包括两个控件点和一个终点原文:An array of POINTAPI structures. The first structure specifies the starting point. The remaining points are in groups of three, consisting of two control points and an end point. 
    cPoints Long,lppt数组的总点数  
      

  2.   

    Private Declare Function PolyBezier Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long) As Long 'cPoints 必须是这样的数 3*n+1,试试下面的代码
    Private Type POINTAPI
      x As Long
      y As Long
    End Type
    Dim bpoints(47) As POINTAPIPrivate Sub Command1_Click()
    Dim I As Integer
    Dim j As Long
    Picture1.Scale (0, 0)-(640, 480)
    Picture1.ScaleMode = 3   '------------------>设置scalemode属性为pixels(像素),将API默认的坐标系和vb中使用的坐标系对应起来
    For I = 0 To 47
    bpoints(I).x = 32 + I * 20
    'bpoints(I).y = 200 + 300 * Sin(bpoints(I).x * 2 * 3.1415926 / 640)
    bpoints(I).y = 60 + 20 * Sin((bpoints(I).x * 2 * 3.14159 / 640))
    Picture1.PSet (bpoints(I).x, bpoints(I).y), QBColor(12)
    Next' PolyBezier Picture1.hdc, bpoints(0), 45
        PolyBezier Picture1.hdc, bpoints(0), 46 '只有这一句能实现
      '    PolyBezier Picture1.hdc, bpoints(0), 47
       
    End Sub