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


C# Canvas.DrawCircle方法代码示例

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


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

示例1: HandleShapeDraw

		protected virtual void HandleShapeDraw (Canvas canvas)
		{
			// We need to account for offsetting the coordinates based on the padding
			var x = GetX () + Resize (this.ShapeView.Padding.Left);
			var y = GetY () + Resize (this.ShapeView.Padding.Top);

			switch (ShapeView.ShapeType) {
			case ShapeType.Box:
				HandleStandardDraw (canvas, p => {
					var rect = new RectF (x, y, x + this.Width, y + this.Height);
					if (ShapeView.CornerRadius > 0) {
						var cr = Resize (ShapeView.CornerRadius);
						canvas.DrawRoundRect (rect, cr, cr, p);
					} else {
						canvas.DrawRect (rect, p);
					}
				});
				break;
			case ShapeType.Circle:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p));
				break;
			case ShapeType.CircleIndicator:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p), drawFill: false);
				HandleStandardDraw (canvas, p => canvas.DrawArc (new RectF (x, y, x + this.Width, y + this.Height), QuarterTurnCounterClockwise, 360 * (ShapeView.IndicatorPercentage / 100), false, p), ShapeView.StrokeWidth + 3, false);
				break;
			}
		}
开发者ID:asj-it,项目名称:Xamarin-Forms-Shape,代码行数:27,代码来源:Shape.cs

示例2: OnDraw

		protected override void OnDraw(Canvas canvas)
		{
			base.OnDraw(canvas);
			_buttonBackgroundPaint.Color = _backgroundColor;

			float diameter = _radius * 2;
			float uWidth = PaddingLeft == 0 && PaddingRight == 0 ? diameter : Width - PaddingLeft - PaddingRight;
			float uHeight = PaddingBottom == 0 && PaddingTop == 0 ? diameter : Height - PaddingTop - PaddingBottom;
			float cx = uWidth / 2;
			float cy = uHeight / 2;
			float radius = Math.Min(uWidth - DipToPixels(2), uHeight - DipToPixels(2)) / 2;

			if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
			{
				SetLayerType(LayerType.Software, null);
			}
			_shadowPaint.SetShadowLayer(10, 0, 0, _shadowColor);
			canvas.DrawCircle(cx, cy, radius - 4, _shadowPaint);
			canvas.DrawCircle(cx, cy, radius, _buttonBackgroundPaint);
			
			int sidePadding = (int)(_radius * 0.25);
			int ulPadding = (int)(_radius * (0.25 + _contentScale));
			_drawableContent?.SetBounds(sidePadding, sidePadding, ulPadding, ulPadding);
			_drawableContent?.Draw(canvas);
		}
开发者ID:heith,项目名称:Xamarin.Android.FloatingActionButton,代码行数:25,代码来源:FloatingActionButton.cs

示例3: Draw

 public new void Draw(Canvas canvas, Paint paint)
 {
     int viewWidth = mProgressBar.Width;
     int viewHeight = mProgressBar.Height;
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius), mShadowPaint);
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint);
 }
开发者ID:devxiaruwei,项目名称:MaterialProgressbar,代码行数:7,代码来源:OvalShadow.cs

示例4: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var stokewidth = TapUtil.dptodx (this.stokewidthdp);
            var progresswidth = TapUtil.dptodx (this.progresswidthdp);
            //draw border
            int center = Width / 2;
            nn_paint.SetStyle(Paint.Style.Stroke);
            nn_paint.Color=nn_outcolor;
            nn_paint.StrokeWidth = stokewidth;
            canvas.DrawCircle(center,center, nn_radius-stokewidth, nn_paint);

            //draw remainingsection of progress
            nn_paint.SetStyle (Paint.Style.Fill);
            nn_paint.Color=nn_progressremainingcolor;
            //RectF position is relative toparent
            canvas.DrawCircle(center,center, nn_radius-stokewidth*2, nn_paint);

            //draw progress
            nn_paint.SetStyle (Paint.Style.Stroke);
            nn_paint.Color=nn_progresscolor;
            nn_paint.StrokeWidth = progresswidthdp*2;
            //RectF position is relative toparent
            RectF oval = new RectF (0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5));
            canvas.DrawArc(oval, progresssstartangle, progresssendangle, false, nn_paint);

            //draw avatarcontainer (innercircle)
            nn_paint.SetStyle(Paint.Style.Fill);
            nn_paint.Color=nn_innercontainercolor;
            canvas.DrawCircle(center,center, nn_radius-progresswidth-stokewidth*2, nn_paint);
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:32,代码来源:AvatarProgressRelativeLayout.cs

示例5: OnDraw

			protected override void OnDraw (Canvas canvas)
			{
				canvas.DrawColor (Color.White);

				canvas.Translate (10, 10);

				canvas.SaveLayerAlpha (0, 0, 200, 200, 0x88, SaveFlags.All);

				mPaint.Color = Color.Red;
				canvas.DrawCircle (75, 75, 75, mPaint);
				mPaint.Color = Color.Blue;
				canvas.DrawCircle (125, 125, 75, mPaint);

				canvas.Restore ();
			}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:15,代码来源:Layers.cs

示例6: GetCroppedBitmap

        static Bitmap GetCroppedBitmap (Bitmap bmp, int radius)
        {
            Bitmap sbmp;
            if (bmp.Width != radius || bmp.Height != radius)
                sbmp = Bitmap.CreateScaledBitmap (bmp, radius, radius, false);
            else
                sbmp = bmp;
            var output = Bitmap.CreateBitmap (sbmp.Width,
                             sbmp.Height, Bitmap.Config.Argb8888);
            var canvas = new Canvas (output);

            var paint = new Paint ();
            var rect = new Rect (0, 0, sbmp.Width, sbmp.Height);

            paint.AntiAlias = true;
            paint.FilterBitmap = true;
            paint.Dither = true;
            canvas.DrawARGB (0, 0, 0, 0);
            paint.Color = Color.ParseColor ("#BAB399");
            canvas.DrawCircle (sbmp.Width / 2 + 0.7f, sbmp.Height / 2 + 0.7f,
                sbmp.Width / 2 + 0.1f, paint);
            paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn));
            canvas.DrawBitmap (sbmp, rect, rect, paint);

            return output;
        }
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:26,代码来源:RoundedImageView.cs

示例7: OnDraw

 protected override void OnDraw(Canvas canvas)
 {
     base.OnDraw(canvas);
     var paint = new Paint();
     paint.SetColor(Color);
     canvas.DrawCircle(Width / 2, Height / 2, Width / 2, paint);
 }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:7,代码来源:Circle.cs

示例8: OnDraw

		protected override void OnDraw(Canvas canvas)
		{

			Drawable drawable = this.Drawable;

			if (drawable == null) {
				return;
			}

			if (this.Width == 0 || this.Height == 0) {
				return; 
			}

			if (paint == null) {
				Init ();
			}								

			int circleCenter = Width / 2;

			// circleCenter is the x or y of the view's center
			// radius is the radius in pixels of the cirle to be drawn
			// paint contains the shader that will texture the shape
			canvas.DrawCircle (circleCenter, circleCenter, circleCenter, paint);

		}
开发者ID:billy-lokal,项目名称:Dateifi_Old,代码行数:25,代码来源:RoundedImageView.cs

示例9: Transform

		protected override Bitmap Transform(IBitmapPool bitmapPool, Bitmap source, int outWidth, int outHeight)
		{
			int size = Math.Min(source.Width, source.Height);

			int width = (source.Width - size) / 2;
			int height = (source.Height - size) / 2;

			Bitmap squaredBitmap = Bitmap.CreateBitmap(source, width, height, size, size);
			if (squaredBitmap != source)
			{
				source.Recycle();
			}

			Bitmap bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb8888);

			Canvas canvas = new Canvas(bitmap);
			Paint paint = new Paint();
			BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.Clamp,
					BitmapShader.TileMode.Clamp);
			paint.SetShader(shader);
			paint.AntiAlias = true;

			float r = size / 2f;
			canvas.DrawCircle(r, r, r, paint);

			squaredBitmap.Recycle();

			return BitmapResource.Obtain(bitmap, bitmapPool).Get();
		}
开发者ID:thanhdatbkhn,项目名称:GlideXamarinBinding,代码行数:29,代码来源:CircleTransform.cs

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

示例11: Transform

        public Bitmap Transform(Bitmap source)
        {
            int size = Math.Min(source.Width, source.Height);

            int width = (source.Width - size) / 2;
            int height = (source.Height - size) / 2;

            var bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb4444);

            var canvas = new Canvas(bitmap);
            var paint = new Paint();
            var shader =
                new BitmapShader(source, BitmapShader.TileMode.Clamp, BitmapShader.TileMode.Clamp);
            if (width != 0 || height != 0)
            {
                // source isn't square, move viewport to center
                var matrix = new Matrix();
                matrix.SetTranslate(-width, -height);
                shader.SetLocalMatrix(matrix);
            }
            paint.SetShader(shader);
            paint.AntiAlias = true;

            float r = size / 2f;
            canvas.DrawCircle(r, r, r, paint);

            source.Recycle();

            return bitmap;
        }
开发者ID:nepula-h-okuyama,项目名称:DroidKaigi2016Xamarin,代码行数:30,代码来源:CropCircleTransformation.cs

示例12: DrawMask

        public void DrawMask(View target, Canvas maskCanvas, Color maskColor, Point position, int radius, Animator animator)
        {
            // draw solid background
            maskCanvas.DrawColor(maskColor);

            // erase focus area
            maskCanvas.DrawCircle(position.X, position.Y, radius, eraserPaint);
        }
开发者ID:mattleibow,项目名称:AppShowcase,代码行数:8,代码来源:FadeRenderer.cs

示例13: Draw

 internal void Draw(Canvas canvas)
 {
     canvas.DrawCircle(_cells.Last().X, _cells.Last().Y, 3, this);
     for (int p = _cells.Count - 1; p > 0; p--)
     {
         canvas.DrawLine(_cells[p].X, _cells[p].Y, _cells[p - 1].X, _cells[p - 1].Y, this);
     }
 }
开发者ID:Verdungo,项目名称:testRep,代码行数:8,代码来源:Chaser.cs

示例14: HandleShapeDraw

        protected virtual void HandleShapeDraw(Canvas canvas)
        {
            // We need to account for offsetting the coordinates based on the padding
            var x = GetX() + Resize(this.ShapeView.Padding.Left);
            var y = GetY() + Resize(this.ShapeView.Padding.Top);


            HandleStandardDraw(canvas, p => canvas.DrawCircle(x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p));
        }
开发者ID:xDelivered-Patrick,项目名称:Xamarin.Forms.Essentials,代码行数:9,代码来源:CircleView.cs

示例15: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            var paint = new Paint();
            paint.SetARGB(255, 200, 255, 0);
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 4;

            canvas.DrawCircle (200, 200, 180, paint);
        }
开发者ID:pavlinap,项目名称:BullshitBingo,代码行数:9,代码来源:BoardView.cs


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