Bogdan Goie
Bogdan Goie

Reputation: 1307

How to draw a circle with a gap in c#

I am currently trying to display a circle in c# which is cut(has a gap and it's not finished). Is it possible to do this in c# directly or do I need to use some kind of photoshop?

An example of how it should look like is here :

circles

I am trying to utilise this in order to code a program for medical diagnosis. The Circle with gap will increase in size or decrease. Thanks!

Upvotes: 0

Views: 755

Answers (1)

terrybozzio
terrybozzio

Reputation: 4530

you probably mean this:

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.DrawArc(new Pen(Brushes.Black, 8), new Rectangle(50, 50, 100, 100), 10, 340);
        }

The last 2 values(10 and 340 in this case),are the start angle and sweep angle.

EDIT:

To place the flat like ending fill a rectangle on top with the forms backcolor:

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.DrawArc(new Pen(Brushes.Black, 10), new Rectangle(50, 50, 100,100),10, 340);
            e.Graphics.FillRectangle(new SolidBrush(this.BackColor), new Rectangle(142, 85, 14, 30));
        }

For the other ones you will have to play with the coordinates:).

Upvotes: 2

Related Questions