当前位置: 首页>>代码示例>>C#>>正文


C# Region.Complement方法代码示例

本文整理汇总了C#中Region.Complement方法的典型用法代码示例。如果您正苦于以下问题:C# Region.Complement方法的具体用法?C# Region.Complement怎么用?C# Region.Complement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Region的用法示例。


在下文中一共展示了Region.Complement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

	public static void Main () 
	{

		Bitmap bmp = new Bitmap (600, 300);
		Graphics dc = Graphics.FromImage (bmp);        		
		Font fnt = new Font ("Arial", 8);
		Font fnttitle = new Font ("Arial", 8, FontStyle.Underline);
		Matrix matrix = new Matrix ();		
		GraphicsPath patha = new GraphicsPath ();
		GraphicsPath pathb = new GraphicsPath ();
		Pen redPen = new Pen (Color.Red, 2);		
		Region rgn1;
		Region rgn2;		
		int x = 0;		
		
		SolidBrush whiteBrush = new SolidBrush (Color.White);				
		
		dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5);				
		
		/* First*/		
		patha.AddLine (60, 40, 90, 90);
		patha.AddLine (90, 90, 10, 90);
		patha.AddLine (10, 90, 60, 40);			
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse(30, 55, 60, 60);
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Complement (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);			
		dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Second*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);					
		
		dc.DrawPath (redPen, patha);						
				
		pathb.AddEllipse (30+x, 55, 60, 60);						
		dc.DrawPath(redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Exclude (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);				
		dc.DrawString ("Exclude ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140);	
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
		x += 110;
		
		/* Third*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Intersect (rgn2);
		dc.FillRegion (Brushes.Blue, rgn1);		
		dc.DrawString ("Intersect ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;
		
		/* Four*/		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
		patha.AddLine (90+x, 90, 10+x, 90);
		patha.AddLine (10+x, 90, 60+x, 40);			
		
		dc.DrawPath (redPen, patha);		
				
		pathb.AddEllipse (30+x, 55, 60, 60);
		dc.DrawPath (redPen, pathb);
				
		rgn1 = new Region (patha);
		rgn2 = new Region (pathb);				
		rgn1.Xor (rgn2);
		dc.FillRegion(Brushes.Blue, rgn1);		
		dc.DrawString ("Xor ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140);		
		dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));	
		x += 110;	
		
		/* Fifth */		
		patha.Reset ();
		pathb.Reset ();
		patha.AddLine (60+x, 40, 90+x, 90);
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:RegionsGraphicsPath.cs

示例2: Main

	public static void Main () 
	{
		Bitmap bmp = new Bitmap (600, 800);
		Graphics dc = Graphics.FromImage (bmp);        		
		Font fnt = new Font ("Arial", 8);
		Font fnttitle = new Font("Arial", 8, FontStyle.Underline);
		Matrix matrix = new Matrix ();		
		int x = 0;
		Rectangle rect1, rect2, rect3, rect4;		
		Region rgn1, rgn2, rgn3, rgn4;
				
		bool complement = true, exclude = true, union = true, xor = true, intersect = true;
		
		SolidBrush whiteBrush = new SolidBrush (Color.White);				
		
		dc.DrawString ("Region samples using two Rectangle classes", fnttitle, whiteBrush, 5, 5);
				
		/* First */				
		if (complement) {	
			rect1 = new Rectangle (20, 30, 60, 80);		
			rect2 = new Rectangle (50, 40, 60, 80);		
			rgn1 = new Region (rect1);
			rgn2 = new Region (rect2);						
			dc.DrawRectangle (Pens.Green, rect1);				
			dc.DrawRectangle (Pens.Red, rect2);
			rgn1.Complement (rgn2);
			dc.FillRegion (Brushes.Blue, rgn1);		
			dc.DrawString ("Complement ("  + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 130);						
			dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));		
			DumpRegion (rgn1);
		}
		
		/* Second */		
		if (exclude) {
			rect3 = new Rectangle (130, 30, 60, 80);		
			rect4 = new Rectangle (170, 40, 60, 80);		
			rgn3 = new Region (rect3);
			rgn4 = new Region (rect4);			
			dc.DrawRectangle (Pens.Green, rect3);		
			dc.DrawRectangle (Pens.Red, rect4);
			rgn3.Exclude (rgn4);
			dc.FillRegion (Brushes.Blue, rgn3);		
			dc.DrawString ("Exclude ("  + rgn3.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 130, 130);
			dc.DrawRectangles (Pens.Yellow, rgn3.GetRegionScans (matrix));
			DumpRegion (rgn3);
		}
		
		/* Third */
		if (intersect) {		
			
			Rectangle rect5 = new Rectangle (260, 30, 60, 80);		
			Rectangle rect6 = new Rectangle (290, 40, 60, 80);		
			Region rgn5 = new Region (rect5);
			Region rgn6 = new Region (rect6);			
			dc.DrawRectangle (Pens.Green, rect5);		
			dc.DrawRectangle (Pens.Red, rect6);
			rgn5.Intersect (rgn6);
			dc.FillRegion (Brushes.Blue, rgn5);		
			dc.DrawString ("Intersect ("  + rgn5.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 130);
			dc.DrawRectangles (Pens.Yellow, rgn5.GetRegionScans (matrix));
			DumpRegion (rgn5);
		}
		
		/* Four */		
		if (xor) {
			Rectangle rect7 = new Rectangle (380, 30, 60, 80);		
			Rectangle rect8 = new Rectangle (410, 40, 60, 80);		
			Region rgn7 = new Region (rect7);
			Region rgn8 = new Region (rect8);			
			dc.DrawRectangle (Pens.Green, rect7);		
			dc.DrawRectangle (Pens.Red, rect8);
			rgn7.Xor (rgn8);
			dc.FillRegion (Brushes.Blue, rgn7);		
			dc.DrawString ("Xor ("  + rgn7.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 400, 130);
			dc.DrawRectangles (Pens.Yellow, rgn7.GetRegionScans (matrix));
			DumpRegion (rgn7);
		}
		
		/* Fifht */		
		if (union) {
			Rectangle rect9 = new Rectangle (500, 30, 60, 80);		
			Rectangle rect10 = new Rectangle (520, 40, 60, 80);		
			Region rgn9 = new Region(rect9);
			Region rgn10 = new Region(rect10);			
			dc.DrawRectangle (Pens.Green, rect9);		
			dc.DrawRectangle (Pens.Red, rect10);
			rgn9.Union(rgn10);
			dc.FillRegion (Brushes.Blue, rgn9);		
			dc.DrawString ("Union (" + rgn9.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 530, 130);		
			dc.DrawRectangles (Pens.Yellow, rgn9.GetRegionScans (matrix));		
			DumpRegion (rgn9);
		}
		
		dc.DrawString ("Region samples using three Rectangle class", fnttitle, whiteBrush, 5, 155);
		
		/* First */		
		x = 0;		
		
		if (complement) {	
			rect1 = new Rectangle (20+x, 180, 40, 50);		
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:RegionsRectangle.cs


注:本文中的Region.Complement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。