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


C# CGContext.FillEllipseInRect方法代码示例

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


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

示例1: DrawPolkaDotPattern

 // Purple poka dots test
 protected void DrawPolkaDotPattern(CGContext context)
 {
     context.SetFillColor(Color.Purple.ToCGColor());
     context.FillEllipseInRect (new CGRect (4, 4, 8, 8));
 }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:6,代码来源:HatchBrush.cs

示例2: DrawPolkaDotPattern

		// This is our pattern callback. it's called by coregraphics to create 
		// the pattern base.
		protected void DrawPolkaDotPattern (CGContext context)
		{
			context.SetFillColor (.3f, .3f, .3f, 1);
			context.FillEllipseInRect (new RectangleF (4, 4, 8, 8));
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:7,代码来源:Controller.cs

示例3: RenderPages

        public void RenderPages(CGContext context,CGRect rect)
        {
            if (numberOfPages < 2 && HidesForSinglePage)
            {
                return;
            }

            nfloat left = LeftOffset;

            nfloat xOffset = left;
            nfloat yOffset = 0.0f;
            UIColor fillColor = null;
            UIImage image = null;
            CGImage maskingImage = null;
            CGSize maskSize = new CGSize();

            for (uint i = 0; i < numberOfPages; i++)
            {
                NSNumber indexNumber = new NSNumber(i);

                if (i == displayedPage)
                {
                    fillColor = CurrentPageIndicatorTintColor !=null ? CurrentPageIndicatorTintColor : UIColor.White;
                    image = GetImageFromDictionary(currentPageImages,indexNumber);
                    if (null == image)
                    {
                        image = currentPageIndicatorImage;
                    }
                }
                else
                {
                    fillColor = PageIndicatorTintColor !=null ? PageIndicatorTintColor : UIColor.White.ColorWithAlpha (0.3f);
                    image = GetImageFromDictionary(pageImages,indexNumber);
                    if (null == image)
                    {
                        image = pageIndicatorImage;
                    }
                }

                // If no finished images have been set, try a masking image
                if (null == image)
                {
                    maskingImage = GetImageFromDictionary(cgImageMasks,indexNumber);
                    UIImage originalImage = GetImageFromDictionary(pageImageMasks,indexNumber);
                    if (originalImage!=null)
                        maskSize = originalImage.Size;

                    // If no per page mask is set, try for a global page mask!
                    if (null == maskingImage)
                    {
                        maskingImage = pageImageMask;
                        if (pageIndicatorMaskImage!=null)
                            maskSize = pageIndicatorMaskImage.Size;
                    }
                }

                fillColor.SetFill();

                if (image!=null)
                {
                    yOffset = TopOffsetForHeight(image.Size.Height,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - image.Size.Width) / 2.0f);
                    image.Draw(new CGPoint(centeredXOffset, yOffset));
                }
                else if (maskingImage!=null)
                {
                    yOffset = TopOffsetForHeight(maskSize.Height,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - maskSize.Width) / 2.0f);
                    CGRect imageRect = new CGRect(centeredXOffset,yOffset,maskSize.Width,maskSize.Height);
                    context.DrawImage(imageRect,maskingImage);
                }
                else
                {
                    yOffset = TopOffsetForHeight(indicatorDiameter,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - indicatorDiameter) / 2.0f);
                    context.FillEllipseInRect(new CGRect(centeredXOffset,yOffset,indicatorDiameter,indicatorDiameter));
                }

                maskingImage = null;
                xOffset += measuredIndicatorWidth + indicatorMargin;
            }
        }
开发者ID:skela,项目名称:SMPageControl,代码行数:82,代码来源:SMPageControl.cs

示例4: FillEllipsis

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

示例5: DrawPolkaDotPattern

		/// <summary>
		/// This is our pattern callback. it's called by coregraphics to create
		/// the pattern base.
		/// </summary>
		protected void DrawPolkaDotPattern (CGContext context)
		{
			context.FillEllipseInRect (new CGRect (4, 4, 8, 8));
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:8,代码来源:Controller.cs

示例6: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);
		// And draw with a blue fill color
		context.SetFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);

		// Add an ellipse circumscribed in the given rect to the current path, then stroke it
		context.AddEllipseInRect (new CGRect (30, 30, 60, 60));
		context.StrokePath ();

		// Stroke ellipse convenience that is equivalent to AddEllipseInRect(); StrokePath();
		context.StrokeEllipseInRect (new CGRect (30, 120, 60, 60));

		// Fill rect convenience equivalent to AddEllipseInRect(); FillPath();
		context.FillEllipseInRect (new CGRect (30, 210, 60, 60));

		// Stroke 2 seperate arcs
		context.AddArc (150, 60, 30, 0, (float)Math.PI / 2, false);
		context.StrokePath ();
		context.AddArc (150, 60, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
		context.StrokePath ();

		// Stroke 2 arcs together going opposite directions.
		context.AddArc (150, 150, 30, 0, (float)Math.PI / 2, false);
		context.AddArc (150, 150, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
		context.StrokePath ();

		// Stroke 2 arcs together going the same direction..
		context.AddArc (150, 240, 30, 0, (float)(Math.PI / 2), false);
		context.AddArc (150, 240, 30, (float)Math.PI, (float)(3 * Math.PI / 2), false);
		context.StrokePath ();

		// Stroke an arc using AddArcToPoint
		CGPoint[] p = {
			new CGPoint (210, 30),
			new CGPoint (210, 60),
			new CGPoint (240, 60),
		};
		context.MoveTo (p [0].X, p [0].Y);
		context.AddArcToPoint (p [1].X, p [1].Y, p [2].X, p [2].Y, 30);
		context.StrokePath ();

		// Show the two segments that are used to determine the tangent lines to draw the arc.
		context.SetStrokeColor (1, 0, 0, 1);
		context.AddLines (p);
		context.StrokePath ();

		// As a bonus, we'll combine arcs to create a round rectangle!

		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);

		// If you were making this as a routine, you would probably accept a rectangle
		// that defines its bounds, and a radius reflecting the "rounded-ness" of the rectangle.
		var rrect = new CGRect (210, 90, 60, 60);
		var radius = 10;
		// NOTE: At this point you may want to verify that your radius is no more than half
		// the width and height of your rectangle, as this technique degenerates for those cases.

		// In order to draw a rounded rectangle, we will take advantage of the fact that
		// context.AddArcToPoint will draw straight lines past the start and end of the arc
		// in order to create the path from the current position and the destination position.

		// In order to create the 4 arcs correctly, we need to know the min, mid and max positions
		// on the x and y lengths of the given rectangle.
		nfloat minx = rrect.X, midx = rrect.X + rrect.Width / 2, maxx = rrect.X + rrect.Width;
		nfloat miny = rrect.Y, midy = rrect.Y + rrect.Height / 2, maxy = rrect.Y + rrect.Height;

		// Next, we will go around the rectangle in the order given by the figure below.
		//       minx    midx    maxx
		// miny    2       3       4
		// midy   1 9              5
		// maxy    8       7       6
		// Which gives us a coincident start and end point, which is incidental to this technique, but still doesn't
		// form a closed path, so we still need to close the path to connect the ends correctly.
		// Thus we start by moving to point 1, then adding arcs through each pair of points that follows.
		// You could use a similar tecgnique to create any shape with rounded corners.

		// Start at 1
		context.MoveTo (minx, midy);
		// Add an arc through 2 to 3
		context.AddArcToPoint (minx, miny, midx, miny, radius);
		// Add an arc through 4 to 5
		context.AddArcToPoint (maxx, miny, maxx, midy, radius);
		// Add an arc through 6 to 7
		context.AddArcToPoint (maxx, maxy, midx, maxy, radius);
		// Add an arc through 8 to 9
		context.AddArcToPoint (minx, maxy, minx, midy, radius);
		// Close the path
		context.ClosePath ();
		// Fill & stroke the path
		context.DrawPath (CGPathDrawingMode.FillStroke);
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:96,代码来源:CurveDrawing.cs

示例7: drawFilledCircleInContext

 public static void drawFilledCircleInContext(CGContext ctx, CGPoint center, nfloat radius)
 {
     ctx.FillEllipseInRect(new CGRect(center.X - (radius), center.Y - (radius), 2 * radius, 2 * radius));
 }
开发者ID:xabre,项目名称:Xamarin-CircularSlider-SeekArc,代码行数:4,代码来源:Utils.cs


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