2017年11月2日 星期四

[ VB2010 ] - 繪製線條


源自於
http://www.svbr8.url.tw/Prg_Coding/VB/Middle/Drawing/VB_00_00_VB2010/doc.php


Graphics.DrawLine(Pen物件, X1, Y1, X2, Y2)


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(200, 100)
        Dim G As Graphics = Graphics.FromImage(Painting)
        Dim Idx As Integer

        For Idx = 1 To 100 Step 3
            G.DrawLine(Pens.White, 0, Idx, 200, Idx)
            G.DrawLine(Pens.Gray, 0, Idx + 1, 200, Idx + 1)
            G.DrawLine(Pens.Black, 0, Idx + 2, 200, Idx + 2)
        Next

        G.DrawLine(New Pen(Brushes.Red, 7), 30, 1, 10, 100)
        G.DrawLine(New Pen(Brushes.Orange, 6), 27, 1, 20, 100)
        G.DrawLine(New Pen(Brushes.Yellow, 5), 24, 1, 30, 100)
        G.DrawLine(New Pen(Brushes.Green, 4), 21, 1, 40, 100)
        G.DrawLine(New Pen(Brushes.Blue, 3), 18, 1, 50, 100)
        G.DrawLine(New Pen(Brushes.Indigo, 2), 15, 1, 60, 100)
        G.DrawLine(Pens.Purple, 12, 1, 70, 100)
        G.DrawLine(Pens.Black, 9, 1, 80, 100)
        G.DrawLine(Pens.Gray, 6, 1, 90, 100)
        G.DrawLine(Pens.White, 3, 1, 100, 100)

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

End Class

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...