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


C# Path.AddCircle方法代码示例

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


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

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

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

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

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

示例5: DrawChild

        /// <summary>
        /// Draw one child of this View Group.
        /// </summary>
        /// <param name="canvas">The canvas on which to draw the child</param>
        /// <param name="child">Who to draw</param>
        /// <param name="drawingTime">The time at which draw is occurring</param>
        /// <returns>To be added.</returns>
        /// <since version="Added in API level 1" />
        /// <remarks><para tool="javadoc-to-mdoc">Draw one child of this View Group. This method is responsible for getting
        /// the canvas in the right state. This includes clipping, translating so
        /// that the child's scrolled origin is at 0, 0, and applying any animation
        /// transformations.</para>
        /// <para tool="javadoc-to-mdoc">
        ///   <format type="text/html">
        ///     <a href="http://developer.android.com/reference/android/view/ViewGroup.html#drawChild(android.graphics.Canvas, android.view.View, long)" target="_blank">[Android Documentation]</a>
        ///   </format>
        /// </para></remarks>
        protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
        {
            if (this.Element.Aspect != Aspect.AspectFit)
            {
                return base.DrawChild(canvas, child, drawingTime);
            }

            using (var path = new Path())
            {
                path.AddCircle(Width / 2, Height / 2, (Math.Min(Width, Height) - 10) / 2, Path.Direction.Ccw);
                canvas.Save();
                canvas.ClipPath(path);
            }

            return base.DrawChild(canvas, child, drawingTime);
        }
开发者ID:spoiledtechie,项目名称:Xamarin-Forms-Labs,代码行数:33,代码来源:CircleImageRenderer.cs

示例6: DrawChild

        protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
        {
            try {
                // Extract properties
                var source = (CircularImage)Element;
                var borderWidth = source.BorderWidth;
                var borderColor = source.BorderColor.ToAndroid();

                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 = borderWidth;
                paint.SetStyle(Paint.Style.Stroke);
                paint.Color = borderColor;

                canvas.DrawPath(path, paint);

                //Properly dispose
                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:Caeno,项目名称:Lib-XamarinForms-Toolkit,代码行数:44,代码来源:CircularImageRenderer.cs

示例7: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            try
            {
                int width = this.Width - this.PaddingLeft - this.PaddingRight;
                int height = this.Height - this.PaddingBottom - this.PaddingTop;
                var radius = Math.Min(width, height) / 2;
                //var strokeWidth = ((float)(5 * Math.Min(width, height))) / 100;
                //radius -= (int)Math.Round(strokeWidth / 2);

                // A revoir: Est-ce que c'est bien centré avec les padding?
                Path path = new Path();
                path.AddCircle(this.PaddingLeft + (width / 2), this.PaddingTop + (height / 2), radius, Path.Direction.Ccw);
                canvas.Save();
                canvas.ClipPath(path);

                base.Draw(canvas);

                canvas.Restore();

                //path = new Path();
                //path.AddCircle(this.PaddingLeft + (width / 2), this.PaddingTop + (height / 2), radius, Path.Direction.Ccw);

                //var paint = new Paint();
                //paint.AntiAlias = true;
                //paint.StrokeWidth = strokeWidth;
                //paint.SetStyle(Paint.Style.Stroke);
                //paint.Color = Color.Black;

                //canvas.DrawPath(path, paint);

                //paint.Dispose();
                path.Dispose();
                return;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
            }
            base.Draw(canvas);
        }
开发者ID:Ideine,项目名称:Xmf2,代码行数:41,代码来源:CircleImageView.cs

示例8: 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;


				Path 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();

				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);

				paint.Dispose();
				path.Dispose();
				return result;
			}
			catch (Exception ex)
			{
			}

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

示例9: Initialize

		void Initialize ()
		{
			// Create Paint for all drawing
			paint = new Paint ();

			// All paths are based on 100-unit clock radius
			//		centered at (0, 0).

			// Define circle for tick marks.
			tickMarks = new Path ();
			tickMarks.AddCircle (0, 0, 90, Path.Direction.Cw);

			// Hour, minute, second hands defined to point straight up.

			// Define hour hand.
			hourHand = new Path ();
			hourHand.MoveTo (0, -60);
			hourHand.CubicTo (0, -30, 20, -30, 5, -20);
			hourHand.LineTo (5, 0);
			hourHand.CubicTo (5, 7.5f, -5, 7.5f, -5, 0);
			hourHand.LineTo (-5, -20);
			hourHand.CubicTo (-20, -30, 0, -30, 0, -60);
			hourHand.Close ();

			// Define minute hand.
			minuteHand = new Path ();
			minuteHand.MoveTo (0, -80);
			minuteHand.CubicTo (0, -75, 0, -70, 2.5f, -60);
			minuteHand.LineTo (2.5f, 0);
			minuteHand.CubicTo (2.5f, 5, -2.5f, 5, -2.5f, 0);
			minuteHand.LineTo (-2.5f, -60);
			minuteHand.CubicTo (0, -70, 0, -75, 0, -80);
			minuteHand.Close ();

			// Define second hand.
			secondHand = new Path ();
			secondHand.MoveTo (0, 10);
			secondHand.LineTo (0, -80);
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:39,代码来源:ClockView.cs

示例10: getRoundedShape

		public static Bitmap getRoundedShape(Bitmap scaleBitmapImage, int targetWidth, int targetHeight)
		{
			
			Bitmap targetBitmap = Bitmap.CreateBitmap(targetWidth,
				targetHeight, Bitmap.Config.Argb8888);

			Canvas canvas = new Canvas(targetBitmap);
			Android.Graphics.Path path = new Android.Graphics.Path();
			path.AddCircle(((float)targetWidth - 1) / 2,
				((float)targetHeight - 1) / 2,
				(Math.Min(((float)targetWidth),
					((float)targetHeight)) / 2),
				Android.Graphics.Path.Direction.Ccw);


			canvas.ClipPath(path);
			Bitmap sourceBitmap = scaleBitmapImage;
			canvas.DrawBitmap(sourceBitmap,
				new Rect(0, 0, sourceBitmap.Width,
					sourceBitmap.Height),
				new Rect(0, 0, targetWidth, targetHeight), null);
			return targetBitmap;
		}
开发者ID:aocsa,项目名称:CInca,代码行数:23,代码来源:Configuration.cs

示例11: DrawChild

 protected override bool DrawChild(Android.Graphics.Canvas canvas, Android.Views.View child, long drawingTime)
 {
     try
     {
         var element = (RoundedImage)Element;
         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;
         //TODO look for a correct way to assign the BorderWidth depending of the screen dpi
         paint.StrokeWidth = (float)element.BorderWidth;
         paint.SetStyle(Paint.Style.Stroke);
         paint.Color = element.BorderColor.ToAndroid();
         canvas.DrawPath(path, paint);
         //Properly dispose
         paint.Dispose();
         path.Dispose();
         return result;
     }
     catch (Exception ex)
     {
         //Why this happend
         Console.WriteLine(ex.Message);
     }
     return base.DrawChild(canvas, child, drawingTime);
 }
开发者ID:codercampos,项目名称:CrossFeaturesXamarin,代码行数:37,代码来源:RoundedImageRenderer.cs

示例12: DrawRing

        private void DrawRing(Canvas c)
        {
            var sc = c.Save();

            c.Rotate(-this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //������Բ Path ����һ�� Բ����ʾ����, ���ڿ���Բ
            var pInner = new Path();
            pInner.AddCircle(cx, cy, this.BitmapRadius + SPACE / 2, Path.Direction.Cw);
            var pOut = new Path();
            pOut.AddCircle(cx, cy, this.Radius, Path.Direction.Cw);

            c.ClipPath(pOut);
            c.ClipPath(pInner, Region.Op.Difference);

            //var color = new Color((int)(DateTime.Now.Ticks % 0xFFFFFFFF));
            //c.DrawColor(color);

            //�ýǶȽ��������Բ�ķ�Χ
            var g = new SweepGradient(cx, cy, Color.Green, Color.Transparent);
            var paint = new Paint();
            paint.SetShader(g);
            c.DrawCircle(cx, cy, this.Radius, paint);

            c.RestoreToCount(sc);
        }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:30,代码来源:CenterView.cs

示例13: DrawBitmap

        private void DrawBitmap(Canvas c, Bitmap bmp)
        {
            var sc = c.Save();

            this.Degree = this.Degree % 360 + DEGREE_STEP;
            //Ҫ����ת����ͼ����Ч��
            c.Rotate(this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //�޶���ʾ��Χ, ָ���뾶��Բ
            var path = new Path();
            path.AddCircle(cx, cy, this.BitmapRadius, Path.Direction.Cw);
            c.ClipPath(path);
            c.DrawColor(Color.White);

            //ͼƬ�Ļ��Ʒ�Χ
            var w = (this.ShowType == ShowTypes.Inner ? this.IWH : this.OWH) / 2;
            var rect = new Rect(cx - w, cy - w, cx + w, cy + w);

            //����ͼƬ
            var paint = new Paint();
            //srcΪnull, ��������ͼƬ��ΪԴ
            c.DrawBitmap(bmp, null, rect, paint);

            c.RestoreToCount(sc);
        }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:29,代码来源:CenterView.cs

示例14: DrawWater

 void DrawWater(Canvas canvas)
 {
     canvas.Save ();
     var circle = new Path ();
     circle.AddCircle (Width / 2, Height / 2, Height / 2, Path.Direction.Ccw);
     circle.Close ();
     canvas.ClipPath (circle);
     wavy.Draw (canvas);
     canvas.Restore ();
 }
开发者ID:modulexcite,项目名称:bikr,代码行数:10,代码来源:CircleBadge.cs

示例15: DrawChild

		/// <summary>
		/// Draw one child of this View Group.
		/// </summary>
		/// <param name="canvas">The canvas on which to draw the child</param>
		/// <param name="child">Who to draw</param>
		/// <param name="drawingTime">The time at which draw is occurring</param>
		/// <returns>To be added.</returns>
		/// <since version="Added in API level 1" />
		/// <remarks><para tool="javadoc-to-mdoc">Draw one child of this View Group. This method is responsible for getting
		/// the canvas in the right state. This includes clipping, translating so
		/// that the child's scrolled origin is at 0, 0, and applying any animation
		/// transformations.</para>
		/// <para tool="javadoc-to-mdoc">
		///   <format type="text/html">
		///     <a href="http://developer.android.com/reference/android/view/ViewGroup.html#drawChild(android.graphics.Canvas, android.view.View, long)" target="_blank">[Android Documentation]</a>
		///   </format>
		/// </para></remarks>
		protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
		{
			if (this.Element.Aspect == Aspect.AspectFit)
			{
				var radius = Math.Min(Width, Height)/2;
				var strokeWidth = 10;
				radius -= strokeWidth/2;

				Path 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);

				path.Dispose();

				return result;

			}

			return base.DrawChild(canvas, child, drawingTime);
		}
开发者ID:Jaskomal,项目名称:Xamarin-Forms-Labs,代码行数:40,代码来源:CircleImageRenderer.cs


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