A
A
Artur Panteleev2013-12-13 19:31:57
Programming
Artur Panteleev, 2013-12-13 19:31:57

Shading part of "Yin-Yang" shape c#?

iisz4nfynusx.jpg
Hello everyone, I'm interested in what method you can paint over the drop-shaped part of the figure (black in the figure). I can’t understand, because I drew it with two arcs, and fillPie won’t fit accordingly ((

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mrrl, 2013-12-15
@arturpanteleev

The easiest way is to alternate drawing in black and white - draw a black semicircle, then 4 circles and an outer circle. Something like this:

private static void DrawYinYang(Graphics gr,int xctr,int yctr,int rmax,int rint,int ysmall,int rsmall) {
            Brush white=Brushes.White;
            Brush black=Brushes.Black;
            Pen BlackPen=new Pen(Color.Black,2*(rmax-rint));

            gr.FillPie(black,xctr-rmax,yctr-rmax,2*rmax,2*rmax,-90,180);
            gr.FillEllipse(white,xctr-rint/2,yctr-rint,rint,rint);
            gr.FillEllipse(black,xctr-rint/2,yctr,rint,rint);
            gr.FillEllipse(white,xctr-rsmall,yctr+ysmall-rsmall,2*rsmall,2*rsmall);
            gr.FillEllipse(black,xctr-rsmall,yctr-ysmall-rsmall,2*rsmall,2*rsmall);
            double rcircle=(rmax+rint)/2.0;
            gr.DrawEllipse(BlackPen,(float)(xctr-rcircle),(float)(yctr-rcircle),(float)(2*rcircle),(float)(2*rcircle));
        }

If you really want to paint over a curvilinear figure, you need to study what GraphicPath is and use FIllRegion. But I haven't tried that.

A
aleyer, 2013-12-14
@aleyer

I think after looking at this image, everything will become clear. The 2 teardrop shapes are pie split in half and 2 circles with a diameter of half the symbol's diameter.
I won’t tell you about the implementation in C #, I don’t know it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question