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


C# CGContext.AddRect方法代码示例

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


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

示例1: FillRect

 public static void FillRect(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetFillColor(color);
     context.FillRect(rect);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例2: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetRGBStrokeColor (1, 1, 1, 1);
		// And drawing with a blue fill color
		context.SetRGBFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);
		
		// Add Rect to the current path, then stroke it
		context.AddRect (new RectangleF (30, 30, 60, 60));
		context.StrokePath ();
		
		// Stroke Rect convenience that is equivalent to above
		context.StrokeRect (new RectangleF (30, 120, 60, 60));
		
		// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 10);
		// Demonstate the stroke is on both sides of the path.
		context.SaveState ();
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 2);
		context.RestoreState ();
		
		var rects = new RectangleF []
		{
			new RectangleF (120, 30, 60, 60),
			new RectangleF (120, 120, 60, 60),
			new RectangleF (120, 210, 60, 60),
		};
		// Bulk call to add rects to the current path.
		context.AddRects (rects);
		context.StrokePath ();
		
		// Create filled rectangles via two different paths.
		// Add/Fill path
		context.AddRect (new RectangleF (210, 30, 60, 60));
		context.FillPath ();
		// Fill convienience.
		context.FillRect (new RectangleF (210, 120, 60, 60));
	}	
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:41,代码来源:PolyDrawing.cs

示例3: AddRoundedRectToPath

		public static void AddRoundedRectToPath(CGContext context, RectangleF rect, float ovalWidth, float ovalHeight)
		{
			float fw, fh;
			if (ovalWidth == 0 || ovalHeight == 0)
			{
				context.AddRect(rect);
				return;
			}
			context.SaveState();
			context.TranslateCTM(rect.GetMinX(), rect.GetMinY());
			context.ScaleCTM(ovalWidth, ovalHeight);
			fw = rect.Width / ovalWidth;
			fh = rect.Height / ovalHeight;
			context.MoveTo(fw, fh / 2);
			context.AddArcToPoint(fw, fh, fw / 2, fh, 1);
			context.AddArcToPoint(0, fh, 0, fh / 2, 1);
			context.AddArcToPoint(0, 0, fw / 2, 0, 1);
			context.AddArcToPoint(fw, 0, fw, fh / 2, 1);
			context.ClosePath();
			context.RestoreState();
		}
开发者ID:modulexcite,项目名称:artapp,代码行数:21,代码来源:ImageHelper.cs

示例4: FillGradient

 public static void FillGradient(CGContext context, RectangleF rect, CGColor color1, CGColor color2)
 {
     CGGradient gradientBackground;
     CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
     
     float[] locationListBackground = new float[] { 1.0f, 0.0f };
     List<float> colorListBackground = new List<float>();
     colorListBackground.AddRange(color1.Components);
     colorListBackground.AddRange(color2.Components);
     gradientBackground = new CGGradient(colorSpace, colorListBackground.ToArray(), locationListBackground);
     
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     //context.ScaleCTM(1, -1);
     context.DrawLinearGradient(gradientBackground, new PointF(rect.X, rect.Y), new PointF(rect.X + rect.Width, rect.Y + rect.Height), CGGradientDrawingOptions.DrawsBeforeStartLocation);
     context.RestoreState();
 }       
开发者ID:pascalfr,项目名称:MPfm,代码行数:18,代码来源:CoreGraphicsHelper.cs

示例5: DrawBackground

        private void DrawBackground(CGContext context)
        {
            context.SetFillDialogBorderColor();
            context.AddRect(
                new RectangleF(Frame.X - Border,
                               Frame.Y - Border,
                               Frame.Width + 2 * Border,
                               Frame.Height + 2 * Border));

            context.DrawPath(CGPathDrawingMode.Fill);

            context.SetFillDialogBackgroungColor();
            context.AddRect(Frame);
            context.DrawPath(CGPathDrawingMode.Fill);
        }
开发者ID:ThunderMasta,项目名称:DyedSudoku,代码行数:15,代码来源:DialogViewModel.cs


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