Example usage for android.graphics Canvas drawArc

List of usage examples for android.graphics Canvas drawArc

Introduction

In this page you can find the example usage for android.graphics Canvas drawArc.

Prototype

public void drawArc(@NonNull RectF oval, float startAngle, float sweepAngle, boolean useCenter,
        @NonNull Paint paint) 

Source Link

Document

Draw the specified arc, which will be scaled to fit inside the specified oval.

Usage

From source file:Main.java

public static Bitmap createRoundedBottomBitmap(Context context, int width, int height, int color) {

    Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    //color = 0x80424242;  // FIXME

    final Paint paint = new Paint();
    final int roundPxInt = convertDipsToPixels(context, ROUND_DIPS);

    final Rect rect = new Rect(0, 0, width, height - roundPxInt);
    final RectF rectF = new RectF(rect);
    final Rect rectRound = new Rect(roundPxInt, height - roundPxInt, width - roundPxInt, height);
    final RectF rectFRound = new RectF(rectRound);

    paint.setAntiAlias(true);/* w  w w.j  a  v a 2  s.  c  o m*/
    paint.setColor(color);

    canvas.drawARGB(0, 0, 0, 0);

    // Corners
    Rect oval = new Rect(0, height - 2 * roundPxInt, 2 * roundPxInt, height);
    RectF ovalF = new RectF(oval);
    canvas.drawArc(ovalF, 90.0f, 90.0f, true, paint);

    oval = new Rect(width - 2 * roundPxInt, height - 2 * roundPxInt, width, height);
    ovalF = new RectF(oval);
    canvas.drawArc(ovalF, 0.0f, 90.0f, true, paint);

    // Big and small rectangles
    canvas.drawRect(rectF, paint);
    canvas.drawRect(rectFRound, paint);

    return output;
}

From source file:com.efunds.moa.component.customview.process.AnnularView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float mAngle = mProgress * 360f / mMax;
    canvas.drawArc(mBound, 270, mAngle, false, mWhitePaint);
    canvas.drawArc(mBound, 270 + mAngle, 360 - mAngle, false, mGreyPaint);
}

From source file:io.jawg.osmcontributor.ui.utils.views.customs.ImageProgressBar.java

private void drawCircle(Canvas canvas, float level, int color) {
    paint.setColor(color);/*ww  w .ja  va 2  s .c  om*/
    float angle;
    angle = 360 / 1f;
    angle = level * angle;
    canvas.drawArc(oval, 0, Math.round(angle), false, paint);
}

From source file:com.dmallcott.progressfloatingactionbutton.ProgressView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Note: The starting point will start counting from -90 degrees
    canvas.drawArc(arcBounds, -90 + mStartingProgress * 360 / mTotalProgress,
            mCurrentProgress * 360 / mTotalProgress, true, paint);
}

From source file:com.sonymobile.androidapp.gridcomputing.views.AchievementProgressView.java

/**
 * Method that draws the progress bar.//  w w w  .  j a  v a  2  s  .  co  m
 *
 * @param paramCanvas the canvas
 */
public void onDraw(final Canvas paramCanvas) {
    getDrawingRect(this.mDrawingBounds);
    this.mDrawingBoundsF.set(this.mDrawingBounds);
    float f = this.mOuterArcStrokeWidth / 2.0F;
    this.mDrawingBoundsF.inset(f, f);
    paramCanvas.drawArc(this.mDrawingBoundsF, 0.0F, SWEEP_ANGLE, false, this.mOuterArcPaint);
    f = this.mOuterArcStrokeWidth / 2.0F + this.mInnerArcStrokeWidth / 2.0F;
    this.mDrawingBoundsF.inset(f, f);
    f = this.mCurrentSteps * SWEEP_ANGLE / this.mTotalSteps;
    paramCanvas.drawArc(this.mDrawingBoundsF, START_ANGLE, f, false, this.mInnerArcPaint);
    super.onDraw(paramCanvas);
}

From source file:com.dlazaro66.wheelindicatorview.WheelIndicatorView.java

private void draw(WheelIndicatorItem indicatorItem, RectF surfaceRectF, float angle, Canvas canvas) {
    itemArcPaint.setColor(indicatorItem.getColor());
    itemEndPointsPaint.setColor(indicatorItem.getColor());
    // Draw arc/*w w  w .  j a v a 2s  .c o  m*/
    canvas.drawArc(surfaceRectF, ANGLE_INIT_OFFSET, angle, false, itemArcPaint);
    // Draw top circle
    canvas.drawCircle(minDistViewSize / 2, 0 + itemsLineWidth, itemsLineWidth, itemEndPointsPaint);
    int topPosition = minDistViewSize / 2 - itemsLineWidth;
    // Draw end circle
    canvas.drawCircle(
            (float) (Math.cos(Math.toRadians(angle + ANGLE_INIT_OFFSET)) * topPosition + topPosition
                    + itemsLineWidth),
            (float) (Math.sin(Math.toRadians((angle + ANGLE_INIT_OFFSET))) * topPosition + topPosition
                    + itemsLineWidth),
            itemsLineWidth, itemEndPointsPaint);
}

From source file:com.tr4android.support.extension.drawable.IndeterminateProgressDrawable.java

@Override
public void draw(Canvas canvas) {
    int saveCount = canvas.save();
    canvas.rotate(mRotation, mArcRect.centerX(), mArcRect.centerY());

    float startAngle = -90 + 360 * (mOffset + mStart);
    float sweepAngle = 360 * (mEnd - mStart);
    canvas.drawArc(mArcRect, startAngle, sweepAngle, false, mArcPaint);

    canvas.restoreToCount(saveCount);/*w w  w  .  jav a  2  s.c om*/
}

From source file:com.cuelogic.android.WheelIndicatorView.java

private void drawOnlyArc(WheelIndicatorItem indicatorItem, RectF surfaceRectF, float angle, float repeatAngle,
        Canvas canvas) {
    itemArcPaint.setColor(Color.parseColor("#FF9000"));
    itemEndPointsPaint.setColor(Color.parseColor("#FF9000"));

    // Draw arc//from ww w  .  j  a  v a  2 s.  com
    canvas.drawArc(surfaceRectF, ANGLE_INIT_OFFSET, angle, false, itemArcPaint);

    //        // Draw top circle
    canvas.drawCircle(minDistViewSize / 2, 0 + itemsLineWidth, itemsLineWidth, itemEndPointsPaint);
    int topPosition = minDistViewSize / 2 - itemsLineWidth;

    // Draw end circle
    canvas.drawCircle(
            (float) (Math.cos(Math.toRadians(angle + ANGLE_INIT_OFFSET)) * topPosition + topPosition
                    + itemsLineWidth),
            (float) (Math.sin(Math.toRadians((angle + ANGLE_INIT_OFFSET))) * topPosition + topPosition
                    + itemsLineWidth),
            itemsLineWidth, itemEndPointsPaint);

    //        draw(indicatorItem, wheelBoundsRectF, repeatAngle, canvas);
}

From source file:com.dlazaro66.wheelindicatorview.WheelIndicatorView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.translate(traslationX, traslationY);
    if (circleBackgroundPaint != null)
        canvas.drawCircle(wheelBoundsRectF.centerX(), wheelBoundsRectF.centerY(),
                wheelBoundsRectF.width() / 2 - itemsLineWidth, circleBackgroundPaint);
    canvas.drawArc(wheelBoundsRectF, ANGLE_INIT_OFFSET, 360, false, innerBackgroundCirclePaint);
    drawIndicatorItems(canvas);/*  w w w  .  j a  v  a  2  s .  co  m*/
}

From source file:com.hippo.widget.ProgressView.java

@Override
protected void onDraw(Canvas canvas) {
    int saved = canvas.save();
    canvas.rotate(mTrimRotation, mRectF.centerX(), mRectF.centerY());

    float startAngle = (mTrimStart + mTrimOffset) * 360.0f - 90;
    float sweepAngle = (mTrimEnd - mTrimStart) * 360.0f;
    canvas.drawArc(mRectF, startAngle, sweepAngle, false, mPaint);

    canvas.restoreToCount(saved);//from w w  w  . j av a2  s  .c om

    if (mShouldStartAnimationDrawable) {
        mShouldStartAnimationDrawable = false;
        startAnimationActually();
    }
}