📄 huizhi.frm
字号:
VERSION 5.00
Begin VB.Form huizhi
Caption = "绘制贝塞尔曲线图"
ClientHeight = 4890
ClientLeft = 60
ClientTop = 345
ClientWidth = 5775
LinkTopic = "Form1"
ScaleHeight = 4890
ScaleWidth = 5775
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "结束"
Height = 495
Left = 1800
TabIndex = 2
Top = 60
Width = 1395
End
Begin VB.CommandButton Command1
Caption = "绘制曲线"
Height = 495
Left = 360
TabIndex = 1
Top = 60
Width = 1395
End
Begin VB.PictureBox Picture1
Align = 2 'Align Bottom
BackColor = &H00000000&
FillColor = &H000000FF&
ForeColor = &H000000FF&
Height = 4215
Left = 0
ScaleHeight = 4155
ScaleWidth = 5715
TabIndex = 0
Top = 675
Width = 5775
End
End
Attribute VB_Name = "huizhi"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim xPos(10) As Single, yPos(10) As Single
Dim PosNum As Integer
Private Sub Command1_Click()
Picture1.Scale (0, 0)-(640, 480)
xPos(0) = 80: yPos(0) = 280
xPos(1) = 350: yPos(1) = 200
xPos(2) = 180: yPos(2) = 140
xPos(3) = 200: yPos(3) = 200
For i = 0 To 2
Picture1.Line (xPos(i), yPos(i))-(xPos(i + 1), yPos(i + 1)), QBColor(12)
Next i
PosNum = 3
DrawBezier PosNum
End Sub
Private Sub Command2_Click()
End
End Sub
Sub DrawBezier(ByVal Num As Integer)
Dim c(10) As Single, b(10) As Single, p(10) As Single
Dim q(10) As Single
Dim t As Single, xe As Single, ye As Single
Dim i As Integer, j As Integer, k As Integer
Picture1.PSet (xPos(0), yPos(0))
For i = 0 To PosNum
c(i) = 1
Next i
For i = 2 To PosNum
For j = 1 To i - 1
b(j) = c(j - 1) + c(j)
Next j
For j = 1 To i - 1
c(j) = b(j)
Next j
Next i
For i = 0 To PosNum * 4
t = i / (PosNum * 4)
p(0) = 1: q(0) = 1
For j = 1 To PosNum
p(j) = p(j - 1) * t
q(j) = q(j - 1) * (1 - t)
Next j
For j = 0 To PosNum
b(j) = p(j) * q(PosNum - j)
Next j
xe = 0: ye = 0
For j = 0 To PosNum
xe = xe + c(j) * b(j) * xPos(j)
ye = ye + c(j) * b(j) * yPos(j)
Next j
Picture1.Line -(xe, ye)
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -