本文整理汇总了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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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 ();
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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));
}
示例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);
}