Search code examples
c#system.drawing

How to draw in c#


I am trying to draw the YinYang symbol on C# windows Form Application. So far, I drew the big outer circle and the two innner circles.

I need help on drawing the curve part that runs down the middle of the circle

Also, how would I fill in the small circle and the other half of the circle to be black.

Also, it is possible to draw this without having to have a button (see code).

enter image description here

Here is a snippet of my code:

    private void button1_Click(object sender, EventArgs e)
    {
        Graphics myGraphics = base.CreateGraphics();
        Pen myPen = new Pen(Color.Black);
        SolidBrush mySolidBrush = new SolidBrush(Color.Black);
        myGraphics.DrawEllipse(myPen, 50,50, 150, 150);

        Graphics innerCircle = base.CreateGraphics();
        Pen myPen2 = new Pen(Color.Black);
        SolidBrush mySolidBrush2 = new SolidBrush(Color.Black);
        myGraphics.DrawEllipse(myPen, 118, 75, 20, 20);

        Graphics innerCircle2 = base.CreateGraphics();
        Pen myPen3 = new Pen(Color.Black);
        SolidBrush mySolidBrush3 = new SolidBrush(Color.Black);
        myGraphics.DrawEllipse(myPen, 118, 150, 20, 20);
    }

Solution

  • You do not have to draw a curve, geometry of ying and yang is so beautiful that it lets you draw it only using circles.

    enter image description here

    Sorry for my paint skills, but I think you know what I mean by this pic. You said

    I drew the big outer circle and the two innner circles.

    So use this knowledge again without thinking about curves