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

沒有留言:

張貼留言

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...