简体   繁体   English

在维恩图中填充三个或更多集合的交集

[英]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. 我画圆,但我无法填满3个或更多圆的交点。

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. 现在,您正在尝试与包含两个圆的单个GraphicsPath对象相交无限区域。 Since the region is infinite to begin with, the Intersect method will just return the region occupied by the GraphicsPath object you specific. 由于开始时区域是无限的,所以Intersect方法将只返回您指定的GraphicsPath对象所占据的区域。

To fix this, create your region by passing a GraphicsPath representing the 1st circle to the constructor. 要解决此问题,请通过将表示第一个圆的GraphicsPath传递给构造函数来创建区域。 Then call the Intersect function using a different GraphicsPath containing the 2nd circle. 然后使用包含第二个圆的另一个GraphicsPath调用Intersect函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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