Smiley Face Programming

This is the Smiley face programming mini project which has complete tutorial of creating Graphics programming using vb.net. Creating graphics programming in VB.NET is not easy task. Here we have used DrawEllipse, FillEllipse, DrawArc feature to develop this. Two Four buttons controls will rotate its two eyes to left, right, up and down.

Programming Language: VB.NET

Following 3 Parameters used in this project:
pen : Pen object that determines the color and style of the ellipse.
brush : Brush object that determines the color of the fill.
envelope : Envelope object that represents the bounding rectangle that defines the ellipse.

Source Code:

ublic Class Form1
    'studentprojectguide.com
    Dim xLeft As Integer = 100
    Dim xRight As Integer = 143
    Dim yLeft As Integer = 75
    Dim yRite As Integer = 75

    Private Sub LeftPupilLeft_Click(sender As Object, e As EventArgs) Handles LeftPupilLeft.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        xLeft -= 1

    End Sub

    Private Sub LeftPupilRight_Click(sender As Object, e As EventArgs) Handles LeftPupilRight.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        xLeft += 1
    End Sub

    

    Private Sub RightPupilrite_Click(sender As Object, e As EventArgs) Handles RightPupilrite.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        xRight += 1
    End Sub

    Private Sub leftPupilUp_Click(sender As Object, e As EventArgs) Handles leftPupilUp.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        yLeft -= 1
    End Sub

    Private Sub LeftPupilDown_Click(sender As Object, e As EventArgs) Handles LeftPupilDown.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        yLeft += 1

    End Sub

    Private Sub RightPupilUp_Click(sender As Object, e As EventArgs) Handles RightPupilUp.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        yRite -= 1
    End Sub

    Private Sub RightPupilDown_Click(sender As Object, e As EventArgs) Handles RightPupilDown.Click
        Dim pnt As Graphics
        pnt = Me.CreateGraphics
        Dim pencil As New Pen(Color.Black, 2)
        pnt.DrawEllipse(pencil, 50, 50, 150, 150)
        pnt.FillEllipse(Brushes.Yellow, 50, 50, 150, 150)
        pnt.DrawArc(pencil, 85, 100, 80, 70, 0, 180)
        pnt.FillEllipse(Brushes.Black, 113, 110, 25, 35)
        pnt.FillEllipse(Brushes.White, 90, 70, 25, 35)
        pnt.DrawEllipse(pencil, 90, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xLeft, yLeft, 15, 22)
        pnt.FillEllipse(Brushes.White, 133, 70, 25, 35)
        pnt.DrawEllipse(pencil, 133, 70, 25, 35)
        pnt.FillEllipse(Brushes.Purple, xRight, yRite, 15, 22)
        yRite += 1
    End Sub

End Class

Download Source Code:

download

Video Tutorial:

Anu

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.