如何以形式绘制原始直径?

时间:2011-04-26 13:04:34

标签: vb6

如何用Pset方法绘制原始直径?

我想画一条这样的一行:see image

感谢。

3 个答案:

答案 0 :(得分:2)

打开一个新的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

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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是绘制图形的一种相对较慢的方式,尤其是当您已经可以使用内置函数时。