[英]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.