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


C# CGContext.AddArc方法代码示例

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


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

示例1: addPath

		static void addPath(CGContext context, CGRect rect, float radius, RoundedCorner cornerMask)
		{
			context.MoveTo(rect.X, rect.Y + radius);
			context.AddLineToPoint(rect.X, rect.Y + rect.Height - radius);
			if (((int)cornerMask & (int)RoundedCorner.BottomLeft) != 0) {
				context.AddArc(rect.X + radius, rect.Y + rect.Height - radius, 
					radius, (nfloat)Math.PI, (nfloat)Math.PI / 2, true);
			}
			else {
				context.AddLineToPoint(rect.X, rect.Y + rect.Height);
				context.AddLineToPoint(rect.X + radius, rect.Y + rect.Height);
			}

			context.AddLineToPoint(rect.X + rect.Width - radius, 
				rect.Y + rect.Height);

			if (((int)cornerMask & (int)RoundedCorner.BottomRight) != 0) {
				context.AddArc(rect.X + rect.Width - radius, 
					rect.Y + rect.Height - radius, radius, (nfloat)Math.PI / 2, 0.0f, true);
			}
			else {
				context.AddLineToPoint(rect.X + rect.Width, rect.Y + rect.Height);
				context.AddLineToPoint(rect.X + rect.Width, rect.Y + rect.Height - radius);
			}

			context.AddLineToPoint(rect.X + rect.Width, rect.Y + radius);

			if (((int)cornerMask & (int)RoundedCorner.TopRight) != 0) {
				context.AddArc(rect.X + rect.Width - radius, rect.Y + radius, 
					radius, 0, -(nfloat)Math.PI / 2, true);
			}
			else {
				context.AddLineToPoint(rect.X + rect.Width, rect.Y);
				context.AddLineToPoint(rect.X + rect.Width - radius, rect.Y);
			}

			context.AddLineToPoint(rect.X + radius, rect.Y);

			if (((int)cornerMask & (int)RoundedCorner.TopLeft) != 0) {
				context.AddArc(rect.X + radius, rect.Y + radius, radius, 
					-(nfloat)Math.PI / 2, (nfloat)Math.PI, true);
			}
			else {
				context.AddLineToPoint(rect.X, rect.Y);
				context.AddLineToPoint(rect.X, rect.Y + radius);
			}

			context.ClosePath();
		}
开发者ID:fadafido,项目名称:tojeero,代码行数:49,代码来源:TabButtonRenderer.cs

示例2: DrawInContext

		public override void DrawInContext (CGContext ctx)
		{
			base.DrawInContext (ctx);
			
			var bounds = Bounds;
			var c = new PointF (bounds.GetMidX (), bounds.GetMidY ());
			
			ctx.BeginPath ();
			ctx.MoveTo (c.X, c.Y);
			ctx.AddLineToPoint (bounds.Right, c.Y);
			ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false);
			ctx.AddLineToPoint (c.X, c.Y);
			ctx.SetFillColor (otherColor);
			ctx.FillPath ();
			
			ctx.BeginPath ();
			ctx.MoveTo (c.X, c.Y);
			ctx.AddLineToPoint (bounds.Right, c.Y);
			ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true);
			ctx.AddLineToPoint (c.X, c.Y);
			ctx.SetFillColor (color);
			ctx.FillPath ();
			
		}
开发者ID:GSerjo,项目名称:Seminars,代码行数:24,代码来源:PieChartLayer.cs

示例3: FillRoundedRect

		void FillRoundedRect (RectangleF rect, CGContext context)
		{
			float radius = 10.0f;
			context.BeginPath ();
			context.SetGrayFillColor (0.0f, this.Opacity);
			context.MoveTo (rect.GetMinX () + radius, rect.GetMinY ());
			context.AddArc (rect.GetMaxX () - radius, rect.GetMinY () + radius, radius, (float)(3 * Math.PI / 2), 0f, false);
			context.AddArc (rect.GetMaxX () - radius, rect.GetMaxY () - radius, radius, 0, (float)(Math.PI / 2), false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMaxY () - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMinY () + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false);
			context.ClosePath ();
			context.FillPath ();
		}
开发者ID:jeffboulanger,项目名称:MBProgressHUD-MonoTouch,代码行数:13,代码来源:MbProgressHud.cs

示例4: MakePath

        private float MakePath(CGContext context, RectangleF rect)
        {
            var radius = rect.Bottom * this.cornerRoundness;
            var puffer = rect.Bottom * 0.12f;
            var maxX = rect.Right - (puffer * 2f);
            var maxY = rect.Bottom - puffer;
            var minX = rect.Left + (puffer * 2f);
            var minY = rect.Top + puffer;
            if (maxX - minX < 20f) {
                maxX = rect.Right - puffer;
                minX = rect.Left + puffer;
            }

            context.AddArc (maxX - radius, minY + radius, radius, (float)(Math.PI + (Math.PI / 2)), 0f, false);
            context.AddArc (maxX - radius, maxY - radius, radius, 0, (float)(Math.PI / 2), false);
            context.AddArc (minX + radius, maxY - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false);
            context.AddArc (minX + radius, minY + radius, radius, (float)Math.PI, (float)(Math.PI + Math.PI / 2), false);

            return maxY;
        }
开发者ID:Alxandr,项目名称:CustomBadge,代码行数:20,代码来源:CustomBadgeView.cs

示例5: drawArc

 private void drawArc(CGContext context, CGRect rect)
 {
     var radius = rect.GetMaxY() * badgeCornerRoundness;
     var puffer = new nfloat(Padding(rect));
     var maxX = rect.GetMaxX() - puffer;
     var maxY = rect.GetMaxY() - puffer;
     var minX = rect.GetMinX() + puffer;
     var minY = rect.GetMinY() + puffer;
     double pi = Math.PI;
     context.AddArc(new nfloat(maxX - radius), new nfloat(minY + radius), new nfloat(radius), new nfloat(pi + (pi / 2)), 0, false);
     context.AddArc(new nfloat(maxX - radius), new nfloat(minY - radius), new nfloat(radius), 0, new nfloat(pi / 2), false);
 }
开发者ID:Jurabek,项目名称:Restaurant,代码行数:12,代码来源:UIBarButtonItem.cs

示例6: drawSlicesWithRadius

        void drawSlicesWithRadius(float radius, PointF center, CGContext contextRef)
        {
            bool cgClockwise = !Clockwise;

            uint startingSlice = StartingSlice - 1;

            if (ProgressCounter == 0 && Theme.DrawIncompleteArcIfNoProgress)
            {
                DrawArcInContext(contextRef, center, radius, 0, M_PI * 2, Theme.IncompletedColor.CGColor, cgClockwise);
                return;
            }

            if (!Theme.SliceDividerHidden && Theme.SliceDividerThickness > 0)
            {
                float sliceAngle = (2 * M_PI) / ProgressTotal;

                for (int i =0; i < ProgressTotal; i++) {
                    float startValue = (sliceAngle * i) + sliceAngle * startingSlice;
                    float startAngle, endAngle;
                    if (Clockwise)
                    {
                        startAngle = -M_PI_2 + startValue;
                        endAngle = startAngle + sliceAngle;
                    }
                    else
                    {
                        startAngle = -M_PI_2 - startValue;
                        endAngle = startAngle - sliceAngle;
                    }

                    contextRef.BeginPath();
                    contextRef.MoveTo(center.X, center.Y);
                    contextRef.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise);

                    CGColor color = Theme.IncompletedColor.CGColor;

                    if (i < ProgressCounter)
                    {
                        color = Theme.CompletedColor.CGColor;
                    }

                    contextRef.SetFillColor(color);
                    contextRef.FillPath();
                }
            }
            else
            {
                double originAngle, endAngle;
                double sliceAngle = (2 * M_PI) / ProgressTotal;
                double startingAngle = sliceAngle * startingSlice;
                double progressAngle = sliceAngle * ProgressCounter;

                if (Clockwise) {
                    originAngle = - M_PI_2 + startingAngle;
                    endAngle = originAngle + progressAngle;
                } else {
                    originAngle = - M_PI_2 - startingAngle;
                    endAngle = originAngle - progressAngle;
                }

                DrawArcInContext(contextRef, center, radius, (float)originAngle, (float)endAngle, Theme.CompletedColor.CGColor, cgClockwise);

                if (ProgressCounter < ProgressTotal)
                {
                    DrawArcInContext(contextRef, center, radius, (float)endAngle, (float)originAngle, Theme.IncompletedColor.CGColor, cgClockwise);
                }
            }
        }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:68,代码来源:MDRadialProgressView.cs

示例7: drawSlicesSeparators

        void drawSlicesSeparators(CGContext contextRef, SizeF viewSize, PointF center)
        {
            int outerDiameter = (int)Math.Min(viewSize.Width, viewSize.Height);

            double outerRadius = outerDiameter / 2.0 - internalPadding;
            int innerDiameter = (int)(outerDiameter - Theme.Thickness);
            double innerRadius = innerDiameter / 2.0;
            int sliceCount = (int)ProgressTotal;
            double sliceAngle = (2 * M_PI) / sliceCount;

            contextRef.SetLineWidth(Theme.SliceDividerThickness);
            contextRef.SetStrokeColor(Theme.SliceDividerColor.CGColor);
            contextRef.MoveTo(center.X, center.Y);

            for (int i = 0; i < sliceCount; i++) {
                contextRef.BeginPath();

                double startAngle = sliceAngle * i - M_PI_2;
                double endAngle = sliceAngle * (i + 1) - M_PI_2;

                contextRef.AddArc(center.X, center.Y, (float)outerRadius, (float)startAngle, (float)endAngle, false);
                contextRef.AddArc(center.X, center.Y, (float)innerRadius, (float)endAngle, (float)startAngle, true);
                contextRef.StrokePath();
            }
        }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:25,代码来源:MDRadialProgressView.cs

示例8: DrawArcInContext

 void DrawArcInContext(CGContext context, PointF center, float radius, float startAngle, float endAngle, CGColor color, bool cgClockwise)
 {
     context.BeginPath();
     context.MoveTo(center.X, center.Y);
     context.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise);
     context.SetFillColor(color);
     context.FillPath();
 }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:8,代码来源:MDRadialProgressView.cs

示例9: 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

示例10: draw

        public void draw(CGContext context)
        {
            double radius = Math.Sqrt(Math.Pow((this.center.X - this.point2.X)/2, 2) + Math.Pow((this.center.Y - this.point2.Y)/2, 2));

            context.AddArc(this.center.X, this.center.Y, (float)radius, 0.0f, (float)Math.PI * 2, true);

            _color.SetStroke();

            context.StrokePath();
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:10,代码来源:Circle.cs

示例11: drawUnfilledArcInContext

        public static void drawUnfilledArcInContext(CGContext ctx, CGPoint center, nfloat radius, nfloat lineWidth, nfloat fromAngleFromNorth, nfloat toAngleFromNorth)
        {
            var cartesianFromAngle = (nfloat)CompassToCartesian(ConvertToRadians(fromAngleFromNorth));
            var cartesianToAngle = (nfloat)CompassToCartesian(ConvertToRadians(toAngleFromNorth));
            
            ctx.AddArc(center.X,   // arc start point x
                            center.Y,   // arc start point y
                            radius,     // arc radius from center
                            cartesianFromAngle, cartesianToAngle,
                            false); // iOS flips the y coordinate so anti-clockwise (specified here by 0) becomes clockwise (desired)!

            ctx.SetLineWidth(lineWidth);
            ctx.SetLineCap(CGLineCap.Butt);
            ctx.DrawPath(CGPathDrawingMode.Stroke);
        }
开发者ID:xabre,项目名称:Xamarin-CircularSlider-SeekArc,代码行数:15,代码来源:Utils.cs


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