2017年12月11日 星期一

[ VB2010 ] - 繪製多邊形

[ VB2010 ] - 繪製多邊形

Graphics.DrawPolygon(Pen物件, PointF陣列)
Graphics.FillPolygon(Brush物件, PointF陣列)



Public Class Form1
    Dim Painting As Bitmap

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

    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)
        Dim PT() As PointF

        ReDim PT(3)
        PT(0).X = 140 : PT(0).Y = 110
        PT(1).X = 170 : PT(1).Y = 140
        PT(2).X = 120 : PT(2).Y = 150
        PT(3).X = 140 : PT(3).Y = 110
        G.DrawPolygon(Pens.Black, PT)

        ReDim PT(3)
        PT(0).X = 240 : PT(0).Y = 270
        PT(1).X = 270 : PT(1).Y = 300
        PT(2).X = 220 : PT(2).Y = 310
        PT(3).X = 240 : PT(3).Y = 270
        G.FillPolygon(Brushes.Yellow, PT)
        G.DrawPolygon(Pens.Black, PT)

        Me.BackgroundImageLayout = ImageLayout.None
        Me.BackgroundImage = Painting
    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...