本文整理汇总了C#中Android.Graphics.Canvas.DrawArc方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.DrawArc方法的具体用法?C# Canvas.DrawArc怎么用?C# Canvas.DrawArc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.DrawArc方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
}
示例3: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
Paint paint = new Paint {
Color = Android.Graphics.Color.Blue
};
paint.SetStyle(Paint.Style.Fill);
canvas.DrawArc (_rect, 0, 300, true, paint);
}
示例4: Draw
public override void Draw(Canvas canvas)
{
float startAngle = _currentGlobalAnge - _currentGlobalAngleOffset;
float sweepAngle = _currentSweepAngle;
if (!_modeAppearing)
{
startAngle = startAngle + sweepAngle;
sweepAngle = 360 - sweepAngle - MIN_SWEEP_ANGLE;
}
else
{
sweepAngle += MIN_SWEEP_ANGLE;
}
canvas.DrawArc(fBounds, startAngle, sweepAngle, false, _paint);
}
示例5: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
m_TempRect.Set(0, 0, m_DrawableSize, m_DrawableSize);
m_TempRect.Offset((Width - m_DrawableSize) / 2, (Height - m_DrawableSize) / 2);
m_TempRectF.Set(-0.5f, -0.5f, m_InnerSize + 0.5f, m_InnerSize + 0.5f);
m_TempRectF.Offset((Width - m_InnerSize) / 2, (Height - m_InnerSize) / 2);
canvas.DrawArc(m_TempRectF, 0, 360, true, CirclePaint);
canvas.DrawArc(m_TempRectF,-90, 360 * Progress / Max, true, ProgressPaint);
var iconDrawable = Checked ? PinnedDrawable : UnpinnedDrawable;
iconDrawable.Bounds = m_TempRect;
iconDrawable.Draw(canvas);
m_ShadowDrawable.Bounds = m_TempRect;
m_ShadowDrawable.Draw(canvas);
}
示例6: drawPorcentajeOnCanvas
private void drawPorcentajeOnCanvas(Canvas canvas)
{
base.OnDraw (canvas);
canvas.Save ();
canvas.DrawColor(Android.Graphics.Color.White);
//Obtenemos el centro de nuesto canvas
float x = this.MeasuredWidth / 2;
float y = this.MeasuredHeight / 2;
//Obtenemos el radio R1
//Obtenemos el radio R2
float R1 = 0;
float R2 = 0;
//if (canvas.Width < canvas.Height) {
if (this.MeasuredWidth < this.MeasuredHeight) {
R1 = x;//Obtenemos el radio R1
R2 = x-(x*por_rango/100);
} else {
R1 = y ;//Obtenemos el radio R1
R2 = y-(y *por_rango/100);//Obtenemos el radio R2 que dejamos un 20% de margen
}
//Dibujamos el fondo de nuestro grafico que va ir creciendo de acuerdo al porcentaje descargado
RectF rectF2 = new RectF(x-R1, y-R1,x+R1, y+R1);
mPaintFondo.Color= Android.Graphics.Color.Rgb(19,184,213);
int grados = 0;
grados = 360 * porcentaje / 100;
canvas.DrawArc(rectF2, 270, grados, true, mPaintFondo);
//Fondo superior de nuestro texto
mPaintSuperior.Color= Android.Graphics.Color.Rgb(50,58,69);
canvas.DrawCircle(x,y , R2, mPaintSuperior);
//Texto que nos indica el procentaje descargado
mPaintTexto.SetTypeface (mFace);
mPaintTexto.Color = Color.White;
//Obtenemos el 30 % de radio de nuestro circulo de fondo, el cual sera el tamaño de letra utilzar;
float MYTEXTSIZE = R2 *30/100;
// Get the screen's density scale
float scale = Application.Context.Resources.DisplayMetrics.Density;
//Convert the dps to pixels, based on density scale
int textSizePx = (int) (MYTEXTSIZE * scale + 0.5f);
mPaintTexto.TextSize = textSizePx;
//Obtenemos la posicion para centrar adecuadamente nuesto texto
int xPos = (this.MeasuredWidth / 2);
int yPos = (int) ((this.MeasuredHeight / 2) - ((mPaintTexto.Descent() + mPaintTexto.Ascent()) / 2)) ;
string Texto_Porcentaje =porcentaje.ToString();
canvas.DrawText (Texto_Porcentaje+" %", xPos,yPos, mPaintTexto);
canvas.Restore();
}
示例7: Draw
public void Draw(Canvas c, Rect bounds)
{
RectF arcBounds = mTempBounds;
arcBounds.Set(bounds);
arcBounds.Inset(mStrokeInset, mStrokeInset);
float startAngle = (mStartTrim + mRotation) * 360;
float endAngle = (mEndTrim + mRotation) * 360;
float sweepAngle = endAngle - startAngle;
mPaint.Color = mColors[mColorIndex];
c.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
DrawTriangle(c, startAngle, sweepAngle, bounds);
if (Alpha < 255)
{
mCirclePaint.Color = BackgrounColor;
mCirclePaint.Alpha = 255 - Alpha;
c.DrawCircle(bounds.ExactCenterX(), bounds.ExactCenterY(), bounds.Width() / 2, mCirclePaint);
}
}
示例8: OnDraw
// void ParseAttributes(Android.Content.Res.TypedArray a)
// {
// BarWidth = (int) a.GetDimension(R.styleable.ProgressWheel_barWidth, barWidth);
// RimWidth = (int) a.GetDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);
// SpinSpeed = (int) a.GetDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);
// DelayMillis = (int) a.GetInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
//
// if(DelayMillis < 0)
// DelayMillis = 0;
//
// BarColor = a.GetColor(R.styleable.ProgressWheel_barColor, barColor);
// BarLength = (int) a.GetDimension(R.styleable.ProgressWheel_barLength, barLength);
// TextSize = (int) a.GetDimension(R.styleable.ProgressWheel_textSize, textSize);
// TextColor = (int) a.GetColor(R.styleable.ProgressWheel_textColor, textColor);
//
// Text = a.GetString(R.styleable.ProgressWheel_text);
//
// RimColor = (int) a.GetColor(R.styleable.ProgressWheel_rimColor, rimColor);
// CircleColor = (int) a.GetColor(R.styleable.ProgressWheel_circleColor, circleColor);
// }
//----------------------------------
//Animation stuff
//----------------------------------
protected override void OnDraw(Canvas canvas)
{
base.OnDraw (canvas);
//Draw the rim
canvas.DrawArc(circleBounds, 360, 360, false, rimPaint);
//Draw the bar
if(isSpinning)
canvas.DrawArc(circleBounds, progress - 90, BarLength, false, barPaint);
else
canvas.DrawArc(circleBounds, -90, progress, false, barPaint);
//Draw the inner circle
canvas.DrawCircle((circleBounds.Width() / 2) + RimWidth + WheelPaddingLeft,
(circleBounds.Height() / 2) + RimWidth + WheelPaddingTop,
CircleRadius,
circlePaint);
//Draw the text (attempts to center it horizontally and vertically)
// int offsetNum = 2;
//
// foreach (var s in splitText)
// {
// float offset = textPaint.MeasureText(s) / 2;
//
// canvas.DrawText(s, this.Width / 2 - offset,
// this.Height / 2 + (TextSize * (offsetNum))
// - ((splitText.Length - 1) * (TextSize / 2)), textPaint);
// offsetNum++;
// }
}
示例9: OnDraw
protected override void OnDraw(Canvas canvas)
{
if (!_clockwise)
{
canvas.Scale(-1, 1, _arcRect.CenterX(), _arcRect.CenterY());
}
// Draw the arcs
var arcStart = _startAngle + MAngleOffset + _arcRotation;
var arcSweep = _sweepAngle;
canvas.DrawArc(_arcRect, arcStart, arcSweep, false, _arcPaint);
canvas.DrawArc(_arcRect, arcStart, _progressSweep, false,
_progressPaint);
// Draw the thumb nail
canvas.Translate(_translateX - _thumbXPos, _translateY - _thumbYPos);
_thumb.Draw(canvas);
}
示例10: OnDraw
protected override void OnDraw(Canvas canvas)
{
// All of our positions are using our internal coordinate system.
// Instead of translating
// them we let Canvas do the work for us.
canvas.Translate(translationOffsetX, translationOffsetY);
var progressRotation = CurrentRoatation;
//draw the background
if (!overdraw)
{
canvas.DrawArc(circleBounds, 270, -(360 - progressRotation), false, backgroundColorPaint);
}
//draw the progress or a full circle if overdraw is true
canvas.DrawArc(circleBounds, 270, overdraw ? 360 : progressRotation, false, progressColorPaint);
//draw the marker at the correct rortated position
if (IsMarkerEnabled)
{
var markerRotation = MarkerRotation;
canvas.Save();
canvas.Rotate(markerRotation - 90);
canvas.DrawLine(thumbPosX + thumbRadius / 2.0f * 1.4f, thumbPosY,
thumbPosX - thumbRadius / 2.0f * 1.4f, thumbPosY, markerColorPaint);
canvas.Restore();
}
//draw the thumb square at the correct rotated position
canvas.Save();
canvas.Rotate(progressRotation - 90);
//rotate the square by 45 degrees
canvas.Rotate(45, thumbPosX, thumbPosY);
var rect = new RectF();
rect.Left = thumbPosX - thumbRadius / 3.0f;
rect.Right = thumbPosX + thumbRadius / 3.0f;
rect.Top = thumbPosY - thumbRadius / 3.0f;
rect.Bottom = thumbPosY + thumbRadius / 3.0f;
canvas.DrawRect(rect, thumbColorPaint);
canvas.Restore();
}
示例11: OnDraw
protected override void OnDraw (Canvas canvas)
{
// All of our positions are using our internal coordinate system.
// Instead of translating
// them we let Canvas do the work for us.
canvas.Translate(_translationOffsetX, _translationOffsetY);
float progressRotation = GetCurrentRotation();
// draw the background
if (!_overrdraw) {
canvas.DrawArc(_circleBounds, 270, -(360 - progressRotation), false,
_backgroundColorPaint);
}
// draw the progress or a full circle if overdraw is true
canvas.DrawArc(_circleBounds, 270, _overrdraw ? 360 : progressRotation, false,
_progressColorPaint);
// draw the marker at the correct rotated position
if (_isMarkerEnabled) {
float markerRotation = GetMarkerRotation();
canvas.Save();
canvas.Rotate(markerRotation - 90);
canvas.DrawLine((float) (_thumbPosX + _thumbRadius / 2 * 1.4), _thumbPosY,
(float) (_thumbPosX - _thumbRadius / 2 * 1.4), _thumbPosY, _markerColorPaint);
canvas.Restore();
}
if (IsThumbEnabled()) {
// draw the thumb square at the correct rotated position
canvas.Save();
canvas.Rotate(progressRotation - 90);
// rotate the square by 45 degrees
canvas.Rotate(45, _thumbPosX, _thumbPosY);
_squareRect.Left = _thumbPosX - _thumbRadius / 3;
_squareRect.Right = _thumbPosX + _thumbRadius / 3;
_squareRect.Top = _thumbPosY - _thumbRadius / 3;
_squareRect.Bottom = _thumbPosY + _thumbRadius / 3;
canvas.DrawRect(_squareRect, _thumbColorPaint);
canvas.Restore();
}
}
示例12: OnDraw
protected override void OnDraw (Canvas canvas)
{
base.OnDraw (canvas);
if (Data != null) {
foreach (var c in Data) {
canvas.DrawArc (mCenterOval, c.AngleBegin, c.AngleEnd - c.AngleBegin, false, getPaint (c.KeyColor));
}
IChartable selected = getSelectedItem (mAngleRotate % 360);
//Set Globals for Settings
CurrentCat = selected.Name;
_currentHexColor = selected.KeyColor;
// print above name
mTextPaint.TextSize = mRadius / 10;
mTextPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY);
//canvas.DrawText (selected.Name, mCx, mCy - 70, mTextPaint);
//Instead of using fixed value 70, using a value relative to the screen size
var nameToPrint = selected.Name;
if (selected.Name.Length > 30) {
nameToPrint = selected.Name.Substring (0, 30) + "...";
}
canvas.DrawText (nameToPrint, mCx, mCy - (int)(mCenterOval.Width ()) / 10, mTextPaint);
// print percentage at center
mTextPaint.TextSize = mRadius / 3;
mTextPaint.Color = Color.ParseColor (selected.KeyColor);
//canvas.DrawText (String.Format ("{0:P2}", selected.Percentage), mCx + 10, mCy + 60, mTextPaint);
//redraw the Text with relative value
canvas.DrawText (String.Format ("{0:P2}", selected.Percentage), mCx + 10, mCy + mCenterOval.Width () / 10, mTextPaint);
// print amount
mTextPaint.TextSize = mRadius / 8;
mTextPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY);
//canvas.DrawText (String.Format ("{0:C}", selected.Amount), mCx, mCy + 150, mTextPaint);
//redraw the Text with relative value
canvas.DrawText (String.Format ("{0:C}", selected.Amount), mCx, mCy + mCenterOval.Width () / 5, mTextPaint);
// inner circle
canvas.DrawCircle (mCx, mCy, mInnerCircleRadius, mInnerPaint);
// print tracker
//canvas.DrawCircle (mEndPoint.X, mEndPoint.Y, (float)(LENGTH_LINE_SEGMENT / 2), mMarkerPaint);
//redraw the circle with the value relative to the screen width
canvas.DrawCircle (mEndPoint.X, mEndPoint.Y, (float)(WIDTH / 40), mMarkerPaint);
canvas.DrawLine (mOrginalPoint.X, mOrginalPoint.Y, mEndPoint.X, mEndPoint.Y, mMarkerPaint);
}
}
示例13: DrawYMotion
private void DrawYMotion(Canvas canvas) {
canvas.DrawArc(_oval, 0, -180, true, _firstHalfPaint);
canvas.DrawArc(_oval, -180, -180, true, _secondHalfPaint);
_path.Reset();
_path.MoveTo(0, _half);
_path.CubicTo(0, _axisValue, _diameter, _axisValue, _diameter, _half);
}