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


C# Graphics.Path类代码示例

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


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

示例1: DrawShape

 protected void DrawShape(Canvas canvas)
 {
   Paint paint = new Paint();
   paint.Color = Color;
   switch (Shape)
   {
     case ShapeEnum.RectangleShape:
       canvas.DrawRect(0, 0, ShapeWidth, ShapeHeight, paint);
       break;
     case ShapeEnum.OvalShape:
       canvas.DrawOval(new RectF(0, 0, ShapeWidth, ShapeHeight), paint);
       break;
     case ShapeEnum.TriangleShape:
         Path path = new Path();
         path.MoveTo(ShapeWidth / 2, 0);
         path.LineTo(ShapeWidth, ShapeHeight);
         path.LineTo(0,ShapeHeight);
         path.Close();
       canvas.DrawPath(path, paint);
       break;
     default:
       canvas.DrawCircle(ShapeWidth / 2, ShapeHeight / 2, ShapeWidth / 2, paint); 
       break;
   }
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:25,代码来源:ShapeView.cs

示例2: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            var rect = new RectF(0, 0, 300, 300);
            switch (Shape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.CornflowerBlue });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Crimson });
                    break;
                case Shape.Triangle:

                    var path = new Path();
                    path.MoveTo(rect.CenterX(), rect.Top);
                    path.LineTo(rect.Left, rect.Bottom);
                    path.LineTo(rect.Right, rect.Bottom);
                    path.Close();
                    var paint = new Paint() {Color = Color.Crimson};
                    paint.Color = Color.Gold;
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:Coolerhino,项目名称:MvvmCross-Tutorials,代码行数:27,代码来源:ShapeView.cs

示例3: DrawStopwatch

        public void DrawStopwatch(Canvas canvas)
        {
            canvas.Save();
            canvas.Translate(Width / 2F, Height / 2F);
            
            var tickMarks = new Path();
            tickMarks.AddCircle(0, 0, 90, Path.Direction.Cw);

            var scale = Math.Min(Width, Height) / 2F / 120;
            canvas.Scale(scale, scale);

            var paint = new Paint
            {
                StrokeCap = Paint.Cap.Square,
                Color = new Color(240, 240, 240)
            };

            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 3;
            paint.SetPathEffect(MinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);

            paint.Color = new Color(240, 240, 240);
            paint.StrokeWidth = 4;
            paint.SetPathEffect(FifthMinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);
        }
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:27,代码来源:StopwatchView.cs

示例4: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw(canvas);

            var rect = new RectF(0,0,300,300);
            switch (TheShape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.Aqua });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Red });
                    break;
                case Shape.Triangle:
                    var path = new Path();
                    path.MoveTo(rect.CenterX(), 0);
                    path.LineTo(0, rect.Height());
                    path.LineTo(rect.Width(), rect.Height());
                    path.Close();

                    var paint = new Paint() {Color = Color.Magenta};
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:29,代码来源:CustomDrawShapeView.cs

示例5: DrawingImageView

	public DrawingImageView(Context context, Fragment fragment): base(context) {
		mPaint = new Paint();
		mPaint.AntiAlias = true;
		mPaint.Dither = true;
		mPaint.Color = Color.Yellow;
		mPaint.SetStyle (Paint.Style.Stroke);
		mPaint.StrokeJoin = Paint.Join.Round;
		mPaint.StrokeCap = Paint.Cap.Round;
		mPaint.StrokeWidth = 10;

		cPaint = new Paint ();
		cPaint.Color = Color.Yellow;
		cPaint.StrokeJoin = Paint.Join.Round;
		cPaint.StrokeCap = Paint.Cap.Round;
		cPaint.SetTypeface(Typeface.Default);
		cPaint.TextSize = 40;

		mPath = new Android.Graphics.Path();
		mBitmapPaint = new Paint();
		mBitmapPaint.Color = Color.Yellow;

		DrawingStatus = DrawingType.None;

		_fragment = fragment;
	}
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:25,代码来源:DrawingImageView.cs

示例6: DrawChild

 protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
 {
     try
     {
         var radius = Math.Min(Width, Height) / 2;
         var strokeWidth = 10;
         radius -= strokeWidth / 2;
         //Create path to clip
         var path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         canvas.Save();
         canvas.ClipPath(path);
         var result = base.DrawChild(canvas, child, drawingTime);
         canvas.Restore();
         // Create path for circle border
         path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         var paint = new Paint();
         paint.AntiAlias = true;
         paint.StrokeWidth = 5;
         paint.SetStyle(Paint.Style.Stroke);
         paint.Color = global::Android.Graphics.Color.White;
         canvas.DrawPath(path, paint);
         //Properly dispose
         paint.Dispose();
         path.Dispose();
         return result;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to create circle image: " + ex);
     }
     return base.DrawChild(canvas, child, drawingTime);
 }
开发者ID:colbylwilliams,项目名称:BasicBeer-Forms,代码行数:34,代码来源:CircleImage.cs

示例7: DrawChild

        /// <summary>
        /// 
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="child"></param>
        /// <param name="drawingTime"></param>
        /// <returns></returns>
        protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
        {
            try
            {
                
                var radius = Math.Min(Width, Height) / 2;
                var strokeWidth = ((CircleImage)Element).BorderThickness;
                radius -= strokeWidth / 2;


               

                var path = new Path();
                path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);

                
                canvas.Save();
                canvas.ClipPath(path);

               

                var paint = new Paint();
                paint.AntiAlias = true;
                paint.SetStyle(Paint.Style.Fill);
                paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
                canvas.DrawPath(path, paint);
                paint.Dispose();


                var result = base.DrawChild(canvas, child, drawingTime);

                canvas.Restore();

                path = new Path();
                path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
                

                var thickness = ((CircleImage)Element).BorderThickness;
                if(thickness > 0.0f)
                {
                    paint = new Paint();
                    paint.AntiAlias = true;
                    paint.StrokeWidth = thickness;
                    paint.SetStyle(Paint.Style.Stroke);
                    paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
                    canvas.DrawPath(path, paint);
                    paint.Dispose();
                }
                
                path.Dispose();
                return result;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
            }

            return base.DrawChild(canvas, child, drawingTime);
        }
开发者ID:elviosousa,项目名称:Xamarin.Plugins,代码行数:66,代码来源:ImageCircleRenderer.cs

示例8: CanvasRenderContext

 /// <summary>
 /// Initializes a new instance of the <see cref="CanvasRenderContext" /> class.
 /// </summary>
 /// <param name="scale">The scale.</param>
 public CanvasRenderContext(double scale)
 {
     this.paint = new Paint();
     this.path = new Path();
     this.bounds = new Rect();
     this.pts = new List<float>();
     this.Scale = scale;
 }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:12,代码来源:CanvasRenderContext.cs

示例9: DrawChild

        protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
        {
            try
            {

                var radius = Math.Min(Width, Height) / 2;

                var borderThickness = (float)((CircleImage)Element).BorderThickness;

                int strokeWidth = 0;

                if (borderThickness > 0)
                {
                    var logicalDensity = Xamarin.Forms.Forms.Context.Resources.DisplayMetrics.Density;
                    strokeWidth = (int)Math.Ceiling(borderThickness * logicalDensity + .5f);
                }

                radius -= strokeWidth / 2;

                var path = new Path();
                path.AddCircle(Width / 2.0f, Height / 2.0f, radius, Path.Direction.Ccw);

                canvas.Save();
                canvas.ClipPath(path);

                var paint = new Paint();
                paint.AntiAlias = true;
                paint.SetStyle(Paint.Style.Fill);
                paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
                canvas.DrawPath(path, paint);
                paint.Dispose();

                var result = base.DrawChild(canvas, child, drawingTime);

                canvas.Restore();

                path = new Path();
                path.AddCircle((float) Width / 2, (float) Height / 2, radius, Path.Direction.Ccw);

                if (strokeWidth > 0.0f)
                {
                    paint = new Paint {AntiAlias = true, StrokeWidth = strokeWidth};
                    paint.SetStyle(Paint.Style.Stroke);
                    paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
                    canvas.DrawPath(path, paint);
                    paint.Dispose();
                }

                path.Dispose();
                return result;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
            }

            return base.DrawChild(canvas, child, drawingTime);
        }
开发者ID:onikiri2007,项目名称:TestApp,代码行数:58,代码来源:CircleImageRenderer.cs

示例10: SvgPath

			public SvgPath (Path path, Paint paint)
			{
				this.path = path;
				this.paint = paint;
				measure = new PathMeasure (path, false);
				length = measure.Length;
				region.SetPath (path, maxClip);
				bounds = region.Bounds;
			}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:9,代码来源:SvgHelper.cs

示例11: parse

		internal static Path parse(float[] pPoints) {
			Path path = new Path();
			path.MoveTo(pPoints[0], pPoints[1]);
			for (int i = 2; i < pPoints.Length; i += 2) {
				float x = pPoints[i];
				float y = pPoints[i + 1];
				path.LineTo(x, y);
			}
			return path;
		}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:10,代码来源:SVGPolylineParser.cs

示例12: ShowPath

 private void ShowPath(Canvas canvas, int x, int y, Path.FillType ft, Paint paint)
 {
     canvas.Save();
     canvas.Translate(x, y);
     canvas.ClipRect(0, 0, 120, 120);
     canvas.DrawColor(Color.White);
     mPath.SetFillType(ft);
     canvas.DrawPath(mPath, paint);
     canvas.Restore();
 }
开发者ID:Cheesebaron,项目名称:MonoDroid.PathFillTypes,代码行数:10,代码来源:PathFillSampleView.cs

示例13: Initialize

        public void Initialize()
        {
            _minuteHand = new Path();
            _minuteHand.MoveTo(0, 10);
            _minuteHand.LineTo(0, -55);
            _minuteHand.Close();

            _secondHand = new Path();
            _secondHand.MoveTo(0, -80);
            _secondHand.LineTo(0, 15);
            _secondHand.Close();
        }
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:12,代码来源:StopwatchView.cs

示例14: BuildPath

		public Path BuildPath (float animationProgress, float animationSeek)
		{
			var startAngle = FitChart.StartAngle;
			var valueSweepAngle = base.Value.StartAngle + base.Value.SweepAngle;
			valueSweepAngle -= startAngle;
			var sweepAngle = valueSweepAngle * animationProgress;

			var path = new Path ();
			path.AddArc (base.DrawingArea, startAngle, sweepAngle);

			return path;
		}
开发者ID:frankcalise,项目名称:XamDroid.FitChart,代码行数:12,代码来源:OverdrawValueRenderer.cs

示例15: BuildPath

		public Path BuildPath (float animationProgress, float animationSeek)
		{
			Path path = null;
			if (base.Value.StartAngle <= animationSeek)
			{
				path = new Path ();
				var sweepAngle = CalculateSweepAngle (animationSeek, base.Value);
				path.AddArc (base.DrawingArea, base.Value.StartAngle, sweepAngle);
			}

			return path;
		}
开发者ID:frankcalise,项目名称:XamDroid.FitChart,代码行数:12,代码来源:LinearValueRenderer.cs


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