如何在表格中绘制原始直径?

发布于 2024-11-03 13:07:17 字数 184 浏览 0 评论 0原文

我如何使用 Pset 方法在表格中绘制原始直径?

我想画一条这样的线:查看图片

谢谢。

How i can to Draw Original diameter in form, with Pset method?

i want to draw a line like this : see image

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绳情 2024-11-10 13:07:18

打开一个新的 vb 项目(标准可执行文件)并复制/粘贴此代码。

Option Explicit

Private Sub Form_Load()

    Me.AutoRedraw = True
    Me.ScaleMode = vbPixels

End Sub

Private Sub DrawLine()

    Dim i As Single
    Dim Angle As Single

    Cls

    If Me.ScaleHeight = 0 Then
        Exit Sub
    End If

    If Me.WindowState = vbMinimized Then
        Exit Sub
    End If

    Angle = Atn(Me.ScaleWidth / Me.ScaleHeight)
    For i = 0 To Sqr(Me.ScaleWidth * Me.ScaleWidth + Me.ScaleHeight * Me.ScaleHeight)

       PSet (i * Sin(Angle), i * Cos(Angle))

    Next

End Sub

Private Sub Form_Resize()

    Call DrawLine

End Sub

Open a new vb project (Standard Executable) and copy/paste this code.

Option Explicit

Private Sub Form_Load()

    Me.AutoRedraw = True
    Me.ScaleMode = vbPixels

End Sub

Private Sub DrawLine()

    Dim i As Single
    Dim Angle As Single

    Cls

    If Me.ScaleHeight = 0 Then
        Exit Sub
    End If

    If Me.WindowState = vbMinimized Then
        Exit Sub
    End If

    Angle = Atn(Me.ScaleWidth / Me.ScaleHeight)
    For i = 0 To Sqr(Me.ScaleWidth * Me.ScaleWidth + Me.ScaleHeight * Me.ScaleHeight)

       PSet (i * Sin(Angle), i * Cos(Angle))

    Next

End Sub

Private Sub Form_Resize()

    Call DrawLine

End Sub
森林散布 2024-11-10 13:07:18
Private Sub circleRoutine(aX As Single, aY As Single, Radius As Single, Steps As Single)
    Dim currAngleX As Single
    Dim i As Integer

    aX = aX - Radius * 1 / Steps

    For currAngleX = 0 To Rad(360) Step Steps
        aX = aX + Radius * Sin(currAngleX)
        aY = aY + Radius * Cos(currAngleX)
        Me.PSet (aX, aY)
    Next currAngleX
End Sub
Private Sub circleRoutine(aX As Single, aY As Single, Radius As Single, Steps As Single)
    Dim currAngleX As Single
    Dim i As Integer

    aX = aX - Radius * 1 / Steps

    For currAngleX = 0 To Rad(360) Step Steps
        aX = aX + Radius * Sin(currAngleX)
        aY = aY + Radius * Cos(currAngleX)
        Me.PSet (aX, aY)
    Next currAngleX
End Sub
风尘浪孓 2024-11-10 13:07:18
Private Sub DrawCircle(ByVal X As Single, ByVal Y As Single, ByVal Diameter As Single, ByVal PointsToDraw As Long)

    Dim Angle As Single

    For Angle = 0 To 2 * 3.14159 Step (2 * 3.14159) / PointsToDraw
        Me.PSet (X + Diameter * Sin(Angle) / 2, Y + Diameter * Cos(Angle) / 2), vbRed
    Next
End Sub

您应该知道,您可以使用 Circle 函数来代替。上面的代码可以替换为:

Me.Circle (X,Y), Diameter / 2, vbRed

PSet 是一种相对较慢的绘制图形的方法,特别是当已经有一个可以使用的内置函数时。

Private Sub DrawCircle(ByVal X As Single, ByVal Y As Single, ByVal Diameter As Single, ByVal PointsToDraw As Long)

    Dim Angle As Single

    For Angle = 0 To 2 * 3.14159 Step (2 * 3.14159) / PointsToDraw
        Me.PSet (X + Diameter * Sin(Angle) / 2, Y + Diameter * Cos(Angle) / 2), vbRed
    Next
End Sub

You should be aware that there is a Circle function that you can use instead. The code above could be replaced with:

Me.Circle (X,Y), Diameter / 2, vbRed

PSet is a relatively slow way to draw graphics, especially when there is already a built-in function you can use instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文