vb怎么将多个点用光滑曲线连起来,并画出这条曲线的平均线
最好加上代码平均线是穿过曲折直线的一条直线,lineto不会啊!小弟qq10368483请详解!...
最好加上代码 平均线是穿过曲折直线的一条直线,lineto不会啊! 小弟qq10368483请详解!
展开
3个回答
展开全部
用贝塞尔曲线画就可以了
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
'set the coördinates
pts(0).x = 22: pts(0).y = 33
pts(1).x = 66: pts(1).y = 55
pts(2).x = 177: pts(2).y = 88
pts(3).x = 199: pts(3).y = 111
pts(4).x = 299: pts(4).y = 222
pts(5).x = 80: pts(5).y = 333
PolyBezierTo Me.hdc, pts(0), 6
End Sub
平均线 ??是个什么线????求出平均值后话直线吗?
那就lineto好了
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
Dim pt(0 To 6) As POINTAPI
'set the co?rdinates
pts(0).x = 22: pts(0).y = 33
pts(1).x = 66: pts(1).y = 55
pts(2).x = 177: pts(2).y = 88
pts(3).x = 199: pts(3).y = 111
pts(4).x = 299: pts(4).y = 222
pts(5).x = 80: pts(5).y = 333
For n = 1 To 6
pt(n).x = (pts(n).x + pts(n - 1).x) / 2
pt(n).y = (pts(n).y + pts(n - 1).y) / 2
Next n
PolyBezierTo Me.hdc, pt(0), 6
PolyBezierTo Me.hdc, pts(0), 6
End Sub
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
'set the coördinates
pts(0).x = 22: pts(0).y = 33
pts(1).x = 66: pts(1).y = 55
pts(2).x = 177: pts(2).y = 88
pts(3).x = 199: pts(3).y = 111
pts(4).x = 299: pts(4).y = 222
pts(5).x = 80: pts(5).y = 333
PolyBezierTo Me.hdc, pts(0), 6
End Sub
平均线 ??是个什么线????求出平均值后话直线吗?
那就lineto好了
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
Dim pt(0 To 6) As POINTAPI
'set the co?rdinates
pts(0).x = 22: pts(0).y = 33
pts(1).x = 66: pts(1).y = 55
pts(2).x = 177: pts(2).y = 88
pts(3).x = 199: pts(3).y = 111
pts(4).x = 299: pts(4).y = 222
pts(5).x = 80: pts(5).y = 333
For n = 1 To 6
pt(n).x = (pts(n).x + pts(n - 1).x) / 2
pt(n).y = (pts(n).y + pts(n - 1).y) / 2
Next n
PolyBezierTo Me.hdc, pt(0), 6
PolyBezierTo Me.hdc, pts(0), 6
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询