📄 frmbezier.frm
字号:
VERSION 5.00
Begin VB.Form frmBezier
Caption = "Form1"
ClientHeight = 8985
ClientLeft = 60
ClientTop = 450
ClientWidth = 9615
LinkTopic = "Form1"
ScaleHeight = 8985
ScaleWidth = 9615
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox picBoard
BackColor = &H80000004&
FillColor = &H0000FFFF&
ForeColor = &H000000FF&
Height = 9000
Left = 0
ScaleHeight = 8940
ScaleWidth = 9540
TabIndex = 0
Top = 0
Width = 9600
Begin VB.Timer Timer1
Interval = 1
Left = 960
Top = 5160
End
End
End
Attribute VB_Name = "frmBezier"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Draw As Boolean
Private Type Points
X As Single
Y As Single
End Type
Dim p(100) As Points
Dim nCount%
Private Sub Form_Load()
picBoard.Scale (-100, 100)-(100, -100)
End Sub
Private Sub picBoard_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Draw = True
If Draw = True Then
nCount = nCount + 1
p(nCount).X = X
p(nCount).Y = Y
End If
If Button = 4 Then
Draw = False
nCount = 0
picBoard.Refresh
End If
End Sub
Private Sub picBoard_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call DrawB
End Sub
Private Sub DrawB()
Dim i%, X!, Y!, t!, x1!, y1!
For i = 1 To nCount - 3
For t = 0 To 1 Step 0.01
X = (-t ^ 3 + 3 * t ^ 2 - 3 * t + 1) * p(i).X + (3 * t ^ 3 - 6 * t ^ 2 + 4) * p(i + 1).X + (-3 * t ^ 3 + 3 * t ^ 2 + 3 * t + 1) * p(i + 2).X + (t ^ 3) * p(i + 3).X
Y = (-t ^ 3 + 3 * t ^ 2 - 3 * t + 1) * p(i).Y + (3 * t ^ 3 - 6 * t ^ 2 + 4) * p(i + 1).Y + (-3 * t ^ 3 + 3 * t ^ 2 + 3 * t + 1) * p(i + 2).Y + (t ^ 3) * p(i + 3).Y
picBoard.Line (x1, y1)-(X / 6, Y / 6)
x1 = X / 6: y1 = Y / 6
Next
picBoard.Line (p(i).X, p(i).Y)-(p(i + 1).X, p(i + 1).Y), vbBlue
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -