Lab 6. Graphics
Write an application that draws a smiley face in a Picture Box.
Your smiley does not have to look exactly like this one. You should at minimum use the following functions:
- FillEllipse
- DrawEllipse
- DrawLine
- FillPie
- DrawPie
In addition you must use at least 2 different colors and 2 different widths for your Pen object and 2 different colors for your SolidBrush object.
Here are the suggested steps:
- Make your picture box dimensions easy to use. I used 300 X 300.
- Change the background color of your picture box to white (web colors).
- Change the name of your picture box to picSmiley
- To draw objects to the picturebox use the CreateGraphics functions within the picturebox click event code. For example:
picSmiley.CreateGraphics.FillEllipse(myBrush, 50, 50, 200, 200)
- Create a filled ellipse for the head first. You will need a SolidBrush object for the fillEllipse function. You can create a SolidBrush like this:
Dim myBrush As New SolidBrush(Color.Yellow)
- Then create the black outline around the head. You will need a Pen object to draw this. You can create a Pen object like this:
Dim myPen As New Pen(Color.Black, 2)
The 2 is the width of your line.
- To create the whites of the eyes, you can do the same thing as for the head. Create a filled elipse, then draw an ellipse outline. You will need to change the brush color to white like this:
myBrush.Color = Color.white
- You can change the Pen color and width in the same manner.
- Draw the rest of the smiley including the irises of the eyes, the nose, and the mouth.
- For the nose draw lines to make a triangle.
- For the mouth use FillPie and DrawPie, changing the width of the Pen oject to draw the lips bigger.
For a 10% bonus, add a button that when clicked makes the smiley look left and another button that when clicked makes the smiley look right again.