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


C# CGPath类代码示例

本文整理汇总了C#中CGPath的典型用法代码示例。如果您正苦于以下问题:C# CGPath类的具体用法?C# CGPath怎么用?C# CGPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreatePieSegment

        private UIImage CreatePieSegment(CGSize size, nfloat endAngle)
        {
            // Add the arc
            var arc = new CGPath();

            arc.MoveToPoint(size.Width / 2.0f, size.Height / 2.0f);
            arc.AddLineToPoint(size.Width / 2.0f, 0);
            arc.AddArc(size.Width / 2.0f, size.Height / 2.0f, size.Width / 2.0f, _startAngle, endAngle, false);
            arc.AddLineToPoint(size.Width / 2.0f, size.Height / 2.0f);

            // Stroke the arc
            UIGraphics.BeginImageContextWithOptions(size, false, 0);

            var context = UIGraphics.GetCurrentContext();

            context.AddPath(arc);
            context.SetFillColor(UIColor.FromRGBA(0f, 0f, 0f, 1f).CGColor);
            context.FillPath();

            // Get the mask image
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return image;
        }
开发者ID:Manne990,项目名称:XamTest,代码行数:26,代码来源:CircularProgressViewRenderer.cs

示例2: Draw

        public override void Draw(RectangleF rect)
        {
            var element = Element as CircleView;

            if (element == null) {
                throw new InvalidOperationException ("Element must be a Circle View type");
            }

            //get graphics context
            using(CGContext context = UIGraphics.GetCurrentContext ()){

                context.SetFillColor(element.FillColor.ToCGColor());
                context.SetStrokeColor(element.StrokeColor.ToCGColor());
                context.SetLineWidth(element.StrokeThickness);

                if (element.StrokeDash > 1.0f) {
                        context.SetLineDash (
                        0,
                        new float[] { element.StrokeDash, element.StrokeDash });
                }

                //create geometry
                var path = new CGPath ();

                path.AddEllipseInRect (rect);

                path.CloseSubpath();

                //add geometry to graphics context and draw it
                context.AddPath(path);
                context.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
开发者ID:pragmaticlogic,项目名称:athena,代码行数:33,代码来源:CircleViewRenderer.cs

示例3: CreateShape

        public override void CreateShape(CGPath path, CGContext gctx)
        {
            path.AddRect (new RectangleF (_origin, new SizeF (100, 100)));
            gctx.AddPath (path);

            gctx.DrawPath (CGPathDrawingMode.FillStroke);
        }
开发者ID:martinbowling,项目名称:iBabySmash,代码行数:7,代码来源:SquareView.cs

示例4: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw (rect);

            var gctx = UIGraphics.GetCurrentContext ();

            // setting blend mode to clear and filling with
            // a clear color results in a transparent fill
            gctx.SetFillColor (UIColor.Purple.CGColor);
            gctx.FillRect (rect);

            gctx.SetBlendMode (CGBlendMode.Clear);
            UIColor.Clear.SetColor ();

            // create some cutout geometry
            var path = new CGPath ();
            path.AddLines(new CGPoint[]{
                new CGPoint(100,200),
                new CGPoint(160,100),
                new CGPoint(220,200)});
            path.CloseSubpath();

            gctx.AddPath(path);
            gctx.DrawPath(CGPathDrawingMode.Fill);
        }
开发者ID:yofanana,项目名称:recipes,代码行数:25,代码来源:TransparentRegionView.cs

示例5: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
            this.BackgroundColor = UIColor.Clear;

            //get graphics context
            using (CGContext g = UIGraphics.GetCurrentContext())
            {

                //set up drawing attributes
                g.SetLineWidth(_lineWidth);
                _color.SetFill();
                //_color.SetStroke();
                UIColor.Clear.SetStroke();
                g.SetAlpha(_transparancy);

                //create geometry
                var path = new CGPath();

                path.AddLines(new CGPoint[]{
					new CGPoint (rect.X + rect.Width, rect.Y),
					new CGPoint (rect.X + rect.Width, rect.Y + rect.Height), 
					new CGPoint (rect.X, rect.Y + rect.Height)});

                path.CloseSubpath();

                //add geometry to graphics context and draw it
                g.AddPath(path);
                g.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:31,代码来源:CropperResizerView.cs

示例6: DrawView

		public DrawView (RectangleF frame) : base (frame)
		{
			DrawPath = new CGPath ();
			CurrentLineColor = UIColor.Black;
			PenWidth = 5.0f;
			Lines = new List<VESLine> ();
		}
开发者ID:EssMarkus,项目名称:Drawit,代码行数:7,代码来源:DrawView.cs

示例7: Draw

 public override void Draw (RectangleF rect)
 {
     base.Draw (rect);
     
     //get graphics context
     CGContext gctx = UIGraphics.GetCurrentContext ();
     
     //set up drawing attributes
     gctx.SetLineWidth (2);
     UIColor.Gray.SetFill ();
     UIColor.Black.SetStroke ();
     
     //create geometry
     _path = new CGPath ();
     
     _path.AddLines (new PointF[] { new PointF (110, 100), new PointF (210, 100), new PointF (210, 200), new PointF (110, 200) });
     
     _path.CloseSubpath ();
     
     //add geometry to graphics context and draw it
     gctx.AddPath (_path);
     gctx.DrawPath (CGPathDrawingMode.FillStroke);
     
     _titleLabel.Frame = new RectangleF (5, 5, Bounds.Width - 10, 25);
     this.AddSubview (_titleLabel);
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:26,代码来源:SecondView.cs

示例8: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			animationPath = new CGPath ();
			backgroundImage = new UIImageView (View.Frame);
			View.AddSubview (backgroundImage);

			CreatePath ();

			btnContents.TouchUpInside += (sender, e) => {
				if(ContentsButtonClicked != null)
					ContentsButtonClicked(sender, e);
			};

			btnAnimate.TouchUpInside += (s, e) => {
				
				// create a keyframe animation
				var keyFrameAnimation = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath ("position");
				keyFrameAnimation.Path =  animationPath;
				keyFrameAnimation.Duration = 3;
				
				keyFrameAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseInEaseOut);
				
				imgToAnimate.Layer.AddAnimation (keyFrameAnimation, "MoveImage");
				imgToAnimate.Layer.Position = new PointF (700f, 900f);
			};
		}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:28,代码来源:LayerAnimationScreen.xib.cs

示例9: Draw

        public override void Draw(System.Drawing.RectangleF rect)
        {
            //Get the current context
            CGContext ctxt = UIGraphics.GetCurrentContext();
            ctxt.ClearRect(rect);

            //Set up the stroke and fill characteristics
            ctxt.SetLineWidth(3.0f);
            float[] gray = { 0.5f, 0.5f, 0.5f, 1.0f};
            ctxt.SetStrokeColor(gray);
            float[] red = { 0.75f, 0.25f, 0.25f, 1.0f};
            ctxt.SetFillColor(red);

            //Draw a line between the two location points
            ctxt.MoveTo(Loc1.X, Loc1.Y);
            ctxt.AddLineToPoint(Loc2.X, Loc2.Y);
            ctxt.StrokePath();

            var p1Box = new RectangleF(Loc1.X, Loc1.Y, 0.0f, 0.0f);
            var p2Box = new RectangleF(Loc2.X, Loc2.Y, 0.0f, 0.0f);
            var offset = -8.0f;

            foreach(var r in new RectangleF[] {p1Box, p2Box})
            {
                using(var path = new CGPath())
                {
                    var cpath = new CGPath();
                    r.Inflate (new SizeF (offset, offset));
                    cpath.AddElipseInRect(r);
                    ctxt.AddPath(cpath);
                    ctxt.FillPath();
                }
            }
        }
开发者ID:lobrien,项目名称:iPhone-Developer-s-Cookbook-in-Monotouch,代码行数:34,代码来源:MultiTouchView.cs

示例10: DrawEllipse

        /// <summary>
        /// Draws an ellipse.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The thickness.</param>
        public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.SetAlias(false);
            var convertedRectangle = rect.Convert();
            if (fill.IsVisible())
            {
                this.SetFill(fill);
                using (var path = new CGPath())
                {
                    path.AddEllipseInRect(convertedRectangle);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Fill);
            }

            if (stroke.IsVisible() && thickness > 0)
            {
                this.SetStroke(stroke, thickness);

                using (var path = new CGPath())
                {
                    path.AddEllipseInRect(convertedRectangle);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:36,代码来源:CoreGraphicsRenderContext.cs

示例11: ViewDidAppear

		public override void ViewDidAppear (bool animated)
		{
			base.ViewDidAppear (animated);

			// get the initial value to start the animation from
			PointF fromPt = layer.Position;

			// set the position to coincide with the final animation value
			// to prevent it from snapping back to the starting position
			// after the animation completes
			layer.Position = new PointF (200, 300);

			// create a path for the animation to follow
			CGPath path = new CGPath ();
			path.AddLines (new PointF[] { fromPt, new PointF (50, 300), new PointF (200, 50), new PointF (200, 300) });

			// create a keyframe animation for the position using the path
			CAKeyFrameAnimation animPosition = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath ("position");
			animPosition.Path = path;
			animPosition.Duration = 2;

			// add the animation to the layer
			// the "position" key is used to overwrite the implicit animation created
			// when the layer positino is set above
			layer.AddAnimation (animPosition, "position");
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:26,代码来源:ExplicitLayerAnimation.cs

示例12: DrawMapRect

 /// <summary>
 /// Draws the map rectangle.
 /// </summary>
 /// <param name="mapRect">Map rectangle.</param>
 /// <param name="zoomScale">Zoom scale.</param>
 /// <param name="context"> Graphics context.</param>
 public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context)
 {
     base.DrawMapRect(mapRect, zoomScale, context);
     var multiPolygons = (MultiPolygon)this.polygonOverlay;
     foreach (var item in multiPolygons.Polygons)
     {
         var path = new CGPath();
         this.InvokeOnMainThread(() =>
             {
                 path = PolyPath(item.Polygon);
             });
         if (path != null)
         {
             context.SetFillColor(item.FillColor);
             context.BeginPath();
             context.AddPath(path);
             context.DrawPath(CGPathDrawingMode.EOFill);
             if (item.DrawOutlines)
             {
                 context.BeginPath();
                 context.AddPath(path);
                 context.StrokePath();
             }
         }
     }
 }
开发者ID:MilenPavlov,项目名称:treewatch,代码行数:32,代码来源:MultiPolygonView.cs

示例13: Clear

 // clear the canvas
 public void Clear()
 {
     drawPath.Dispose ();
     drawPath = new CGPath ();
     fingerDraw = false;
     SetNeedsDisplay ();
 }
开发者ID:bertouttier,项目名称:ExpenseApp-Mono,代码行数:8,代码来源:UIDrawView.cs

示例14: Draw

        public override void Draw(CGRect rect)
        {
            //get graphics context
            using (CGContext g = UIGraphics.GetCurrentContext())
            {
                //set up drawing attributes
                UIColor.Black.SetFill();

                //create geometry
                _overlay = new CGPath();
                
                _overlay.AddRect(new RectangleF(0f, 0f, _width, _height));
                
                if(_isRound)
                    _overlay.AddEllipseInRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));
                else
                    _overlay.AddRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));

                g.SetStrokeColor(UIColor.Clear.CGColor);
                g.SetAlpha(0.6f);

                //add geometry to graphics context and draw it
                g.AddPath(_overlay);
                g.DrawPath(CGPathDrawingMode.EOFillStroke);                
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:26,代码来源:CropperOverlayView.cs

示例15: ShipSprite

        public ShipSprite(PointF initialPosition)
            : base(NSBundle.MainBundle.PathForResource ("spaceship", "png"))
        {
            CGPath boundingPath = new CGPath ();
            boundingPath.MoveToPoint (-12f, -38f);
            boundingPath.AddLineToPoint (12f, -38f);
            boundingPath.AddLineToPoint (9f, 18f);
            boundingPath.AddLineToPoint (2f, 38f);
            boundingPath.AddLineToPoint (-2f, 38f);
            boundingPath.AddLineToPoint (-9f, 18f);
            boundingPath.AddLineToPoint (-12f, -38f);
            #if false
            // Debug overlay
            SKShapeNode shipOverlayShape = new SKShapeNode () {
                Path = boundingPath,
                StrokeColor = UIColor.Clear,
                FillColor = UIColor.FromRGBA (0f, 1f, 0f, 0.5f)
            };
            ship.AddChild (shipOverlayShape);
            #endif
            var body = SKPhysicsBody.BodyWithPolygonFromPath (boundingPath);
            body.CategoryBitMask = Category.Ship;
            body.CollisionBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge;
            body.ContactTestBitMask = body.CollisionBitMask;
            body.LinearDamping = 0;
            body.AngularDamping = 0.5f;

            PhysicsBody = body;
            Position = initialPosition;
        }
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:30,代码来源:ShipSprite.cs


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