Alex Rivera | Logout

How to join overlapping circles?

Asked 2010-12-16T18:06:53.733
21

I want to visually join two circles that are overlapping so that

AltText

becomes

alt text

I already have methods for partial circles, but now I need to know how large the overlapping angle for earch circle is, and I don't know how to do that.

Anyone got an Idea?

Edit
Report

1 Answer

8

Now this will work 100% for you even the figure is ellipse and any number of figures

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Pen p = new Pen(Color.Red, 2);      

        Rectangle Fig1 = new Rectangle(50, 50, 100, 50);  //dimensions of Fig1
        Rectangle Fig2 = new Rectangle(100, 50, 100, 50); //dimensions of Fig2
        . . .

        DrawFigure(e.Graphics, p, Fig1);   
        DrawFigure(e.Graphics, p, Fig2);
        . . .

        //remember to call  FillFigure after  drawing all figures.
        FillFigure(e.Graphics, p, Fig1); 
        FillFigure(e.Graphics, p, Fig2);
        . . .
    }
    private void DrawFigure(Graphics g, Pen p, Rectangle r)
    {
        g.DrawEllipse(p, r.X, r.Y, r.Width, r.Height);
    }
    private void FillFigure(Graphics g, Pen p, Rectangle r)
    {
        g.FillEllipse(new SolidBrush(this.BackColor), r.X + p.Width, r.Y + p.Width, r.Width - 2 * +p.Width, r.Height - 2 * +p.Width);      //Adjusting Color so that it will leave border and fill 
    }

alt text

answered 2010-12-19T08:00:51.130

Your Answer