2017年12月11日 星期一

VB2010-繪製正弦波

VB2010-繪製正弦波



Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim g As Graphics = Me.CreateGraphics
        Dim D As Single
        Dim X As Single, ShfX As Single
        Dim Y As Single, ShfY As Single
        Dim R As Single
        Dim lX As Single
        Dim lY As Single

        lX = -1000
        lY = -1000
        ShfX = 200
        ShfY = 120
        R = 100

        g.DrawLine(Pens.Black, 0, ShfY, 400, ShfY)
        g.DrawLine(Pens.Black, ShfX, 0, ShfX, 250)

        For D = -180 To 180
            X = D + ShfX
            Y = Math.Sin(D * 3.14192653589 / 180) * R + ShfY

            If lX = -1000 Then
                lX = X
            End If
            If lY = -1000 Then
                lY = Y
            End If

            g.DrawLine(Pens.Black, lX, lY, X, Y)
            lX = X
            lY = Y
        Next

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

End Class


源自於
http://e0935487916.ddns.net/svbr81/index_middle_drawing.php.htm

沒有留言:

張貼留言

WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...