2017年12月11日 星期一

[ VB2010 ] - 繪製10點10分的指針

[ VB2010 ] - 繪製10點10分的指針
   

 Const Cv As Double = 0.0174532

Convert angle: 0.0174532 grad to other units


Select input unit of angle:      0.0174532 grad equals to:







Public Class Form1
    Dim Painting As Bitmap

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Painting = New Bitmap(400, 400)
        Dim G As Graphics = Graphics.FromImage(Painting)

        Const CX As Integer = 200
        Const CY As Integer = 200
        Const Hp As Integer = 10
        Const Hl As Integer = 50
        Const Hw As Integer = 5

        Const Mp As Integer = 10
        Const Ml As Integer = 70
        Const Mw As Integer = 3

        Const Fm As Integer = 90
        Const Fw As Integer = 8

        Const Cv As Double = 0.0174532

        Dim HD As Integer
        Dim MD As Integer
        Dim DP As Pen

        HD = Hp / 12 * 360
        MD = Mp / 60 * 360

        DP = New Pen(Color.Red, Hw)
        G.DrawLine(DP, CX, CY, CSng(CX + Hl * Math.Sin(HD * Cv)), CSng(CY - Hl * Math.Cos(HD * Cv)))

        DP = New Pen(Color.Blue, Mw)
        G.DrawLine(DP, CX, CY, CSng(CX + Ml * Math.Sin(MD * Cv)), CSng(CY - Ml * Math.Cos(MD * Cv)))

        DP = New Pen(Color.Green, Fw)
        G.DrawArc(DP, CX - Fm, CY - Fm, Fm * 2, Fm * 2, 0, 360)


        Me.BackgroundImageLayout = ImageLayout.None
        Me.BackgroundImage = Painting
    End Sub

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







沒有留言:

張貼留言

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...