简体   繁体   中英

fill intersection of three or more sets in venn diagram

i am writing the venn diagram and i have a problem in intersection.

i draw circles but i can't fill the intersection of 3 or more circles.

i fill intersection of two circles with this code

   Graphics g = this.CreateGraphics();
   GraphicsPath path = new GraphicsPath();
   Region region1 = new Region();

   Brush blue = new SolidBrush(Color.Blue);  
   Brush white=new SolidBrush(Color.White);
   Rectangle circle1 = new Rectangle(455, 200, 150, 150);
   Rectangle circle2 = new Rectangle(455, 275, 150, 150);
   g.FillEllipse(blue, circle1);
   g.FillEllipse(blue, circle2);

   path.AddEllipse(circle1);
   path.AddEllipse(circle2);
   region1.Intersect(path);
   g.FillRegion(white, region1);

i mean something like this

图片

Right now you're trying to intersect an infinite region with a single GraphicsPath object containing both of your circles. Since the region is infinite to begin with, the Intersect method will just return the region occupied by the GraphicsPath object you specific.

To fix this, create your region by passing a GraphicsPath representing the 1st circle to the constructor. Then call the Intersect function using a different GraphicsPath containing the 2nd circle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM