📄 frmvirtcompass.frm
字号:
VERSION 5.00
Begin VB.Form frmVirtCompass
BackColor = &H80000011&
BorderStyle = 1 'Fixed Single
Caption = "Virtual Compass"
ClientHeight = 4755
ClientLeft = 45
ClientTop = 330
ClientWidth = 4815
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 317
ScaleMode = 3 'Pixel
ScaleWidth = 321
Begin VB.Line Line4
BorderWidth = 5
X1 = 192
X2 = 160
Y1 = 104
Y2 = 64
End
Begin VB.Line Line3
BorderWidth = 5
X1 = 128
X2 = 160
Y1 = 104
Y2 = 64
End
Begin VB.Line Line2
BorderWidth = 5
X1 = 176
X2 = 176
Y1 = 86
Y2 = 234
End
Begin VB.Line Line1
BorderColor = &H00000000&
BorderWidth = 5
X1 = 144
X2 = 144
Y1 = 86
Y2 = 234
End
Begin VB.Shape Sky
BorderColor = &H00000000&
BorderWidth = 2
FillColor = &H00FFFFFF&
FillStyle = 0 'Solid
Height = 3300
Left = 750
Shape = 3 'Circle
Top = 750
Width = 3300
End
Begin VB.Shape Background
BorderColor = &H00C0C0C0&
BorderWidth = 2
FillColor = &H80000011&
FillStyle = 0 'Solid
Height = 3900
Left = 450
Shape = 3 'Circle
Top = 450
Width = 3900
End
End
Attribute VB_Name = "frmVirtCompass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const Pi As Double = 3.141592
Const W2 As Double = 1.4142
Const MX As Integer = 160
Const MY As Integer = 160
Const R As Integer = 75
Const Rtip As Integer = 96
Const W As Integer = 16
Const Wtop As Integer = 32
Const Rtop As Integer = 56
Private Sub Form_Load()
frmVirtCompass.Top = 5000
frmVirtCompass.Left = 1000
End Sub
Function CalculateArrow(a As Double)
Static L1X1, L1Y1, L1X2, L1Y2, _
L2X1, L2Y1, L2X2, L2Y2, _
L3X1, L3Y1, L3X2, L3Y2, _
L4X1, L4Y1 As Integer
Static alpha As Double, sina As Double, cosa As Double
'Conversion to Radian
' alpha = a * Pi / 180:
alpha = a
sina = Sin(alpha): cosa = Cos(alpha)
'calculate body of arrow
L1X1 = MX - R * sina - W * cosa
L1Y1 = MX - R * cosa + W * sina
L1X2 = MX + R * sina - W * cosa
L1Y2 = MX + R * cosa + W * sina
L2X1 = MX - R * sina + W * cosa
L2Y1 = MX - R * cosa - W * sina
L2X2 = MX + R * sina + W * cosa
L2Y2 = MX + R * cosa - W * sina
'calculate tip
L3X1 = MX - Rtop * sina - Wtop * cosa
L3Y1 = MX - Rtop * cosa + Wtop * sina
L3X2 = MX - Rtip * sina
L3Y2 = MX - Rtip * cosa
L4X1 = MX - Rtop * sina + Wtop * cosa
L4Y1 = MX - Rtop * cosa - Wtop * sina
Call VisualizeBar(L1X1, L1Y1, L1X2, L1Y2, _
L2X1, L2Y1, L2X2, L2Y2, _
L3X1, L3Y1, L3X2, L3Y2, _
L4X1, L4Y1)
End Function
Function VisualizeBar(L1X1, L1Y1, L1X2, L1Y2, _
L2X1, L2Y1, L2X2, L2Y2, _
L3X1, L3Y1, L3X2, L3Y2, _
L4X1, L4Y1 As Integer)
Line1.X1 = L1X1
Line1.Y1 = L1Y1
Line1.X2 = L1X2
Line1.Y2 = L1Y2
Line2.X1 = L2X1
Line2.Y1 = L2Y1
Line2.X2 = L2X2
Line2.Y2 = L2Y2
Line3.X1 = L3X1
Line3.Y1 = L3Y1
Line3.X2 = L3X2
Line3.Y2 = L3Y2
Line4.X1 = L4X1
Line4.Y1 = L4Y1
Line4.X2 = L3X2 'same as Line3
Line4.Y2 = L3Y2
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -