2017年11月2日 星期四

[ VB2010 ] - 畫線與畫圓



源自於
http://www.svbr8.url.tw/Prg_Coding/VB/index_middle_drawing.php


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim BMP As Bitmap = New Bitmap(200, 100, Imaging.PixelFormat.Format32bppArgb)
        Dim g As Graphics = Graphics.FromImage(BMP)
        Dim f As Font = New Font(Me.Font.Name, 12, FontStyle.Bold)

        g.FillRectangle(Brushes.White, 0, 0, 200, 200)
        g.DrawRectangle(Pens.Black, 0, 0, 199, 99)

        g.DrawLine(Pens.Black, 1, 1, 200, 100)
        g.DrawLine(Pens.Black, 1, 1, 200, 50)
        g.DrawLine(Pens.Black, 1, 1, 100, 100)

        g.DrawEllipse(Pens.Black, 15, 5, 10, 12)
        g.DrawEllipse(Pens.Black, 30, 10, 20, 24)
        g.DrawEllipse(Pens.Black, 60, 20, 40, 48)
        g.DrawEllipse(Pens.Black, 120, 40, 80, 96)

        g.DrawString("S", f, Brushes.Red, 5, 55)
        g.DrawString("V", f, Brushes.Orange, 15, 55)
        g.DrawString("B", f, Brushes.Green, 25, 55)
        g.DrawString("R", f, Brushes.Blue, 35, 55)

        g.Dispose()
        Me.BackgroundImageLayout = ImageLayout.None
        Me.BackgroundImage = BMP

    End Sub

End Class

沒有留言:

張貼留言

Messaging API作為替代方案

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