?
Solved

Drawing an Egg Shape !

Posted on 2013-11-27
2
Medium Priority
?
482 Views
Last Modified: 2013-11-28
Here's an odd one...

How can I draw the shape of an egg on screen using vb.net ot c#.net code?
0
Comment
Question by:Dodsworth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 39681847
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:
one possible egg shapeThis 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

Open in new window

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

by:Dodsworth
ID: 39683000
Eggcellent ! The link was truely mind boggling !
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question