繁体   English   中英

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

[英]fill intersection of three or more sets in venn diagram

我正在写维恩图,但在交集时遇到问题。

我画圆,但我无法填满3个或更多圆的交点。

我用此代码填充两个圆圈的交点

   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);

我的意思是这样的

图片

现在,您正在尝试与包含两个圆的单个GraphicsPath对象相交无限区域。 由于开始时区域是无限的,所以Intersect方法将只返回您指定的GraphicsPath对象所占据的区域。

要解决此问题,请通过将表示第一个圆的GraphicsPath传递给构造函数来创建区域。 然后使用包含第二个圆的另一个GraphicsPath调用Intersect函数。

暂无
暂无

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

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