Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Please type the code here using visual studio program and put a color that star too
Posted

1 solution

VB
Imports System.Drawing.Drawing2D

Public Class Form1

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

        Dim StarObject As Graphics = e.Graphics
        Dim i As Integer
        Dim random As Random = New Random()
        Dim brush As SolidBrush = New SolidBrush(Color.CornflowerBlue)

        ' x and y points of the path
        Dim xPoints As Integer() = {55, 67, 109, 73, 83, 55, 27, 37, 1, 43}
        Dim yPoints As Integer() = {0, 36, 36, 54, 96, 72, 96, 54, 36, 36}

        ' create graphics path for star
        Dim star As GraphicsPath = New GraphicsPath()

        ' translate the origin to (100, 100)
        StarObject.TranslateTransform(100, 100)

        ' create star from series of points
        For i = 0 To 8 Step 2
            star.AddLine(xPoints(i), yPoints(i), xPoints(i + 1), yPoints(i + 1))
        Next

        ' close the shape
        star.CloseFigure()

        StarObject.FillPath(brush, star)

    End Sub

End Class
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900