Solved

# Drawing an Egg Shape !

Posted on 2013-11-27
417 Views
Here's an odd one...

How can I draw the shape of an egg on screen using vb.net ot c#.net code?
0
Question by:Dodsworth

LVL 35

Accepted Solution

Robert Schutt earned 500 total points
That depends on what you would describe as an egg shape. Eggs come in many shapes, the simplest being an ellipse. But as you're probably not asking for help on drawing an ellipse I think you're looking for something like this:
This consists of a circle at the bottom and an ellipse (with a vertical radius 50 % larger than the circle) at the top, cut off at 0 and 180 degrees.

Just stick a panel on a form and try this:
``````    Private Sub Panel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim y1 As Integer = Panel1.Height
Dim x1 As Integer = Panel1.Width
Dim y2 As Integer = y1 / 2
Dim x2 As Integer = x1 / 2
Dim y4 As Integer = y1 / 4
Dim x4 As Integer = x1 / 4
Dim y8 As Integer = y1 / 8
Dim x8 As Integer = x1 / 8
With e.Graphics
'.DrawLine(Pens.Gray, 0, y2, x1, y2)
'.DrawLine(Pens.Gray, x2, 0, x2, y1)
'.DrawEllipse(New Pen(Brushes.Gray, 3), x4, y4, x2, y2)
'.DrawEllipse(New Pen(Brushes.Gray, 3), x4, y8, x2, y4 * 3)
.DrawArc(New Pen(Brushes.Black, 3), x4, y4, x2, y2, 0, 180)
.DrawArc(New Pen(Brushes.Black, 3), x4, y8, x2, y4 * 3, 0, -180)
End With
End Sub
``````
EDIT: if you're looking for a mathematical function to plot an egg, here's a page with lots of options: http://www.mathematische-basteleien.de/eggcurves.htm
0

LVL 1

Author Closing Comment

Eggcellent ! The link was truely mind boggling !
0

## Featured Post

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …