Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create triangle. Dim point1 As New Point(15, 65) Dim point2 As New Point(100, 150) Dim point3 As New Point(195, 65) Dim myGraphicsPath As New GraphicsPath myGraphicsPath.AddLine(point1.X, point1.Y, point2.X, point2.Y) myGraphicsPath.AddLine(point1.X, point1.Y, point3.X, point3.Y) myGraphicsPath.AddLine(point3.X, point3.Y, point2.X, point2.Y) Dim myRegion As New Region(myGraphicsPath) Dim myBrush As New SolidBrush(Color.Red) e.Graphics.FillRegion(myBrush, myRegion) ' Create rectangle. Dim rect As New Rectangle(5, 5, 200, 200) ' Draw rectangle to screen. e.Graphics.DrawRectangle(blackPen, rect) End Sub End Class
Last Updated on October 26, 2015