Example usage for android.graphics Canvas drawCircle

List of usage examples for android.graphics Canvas drawCircle

Introduction

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

Prototype

public void drawCircle(float cx, float cy, float radius, @NonNull Paint paint) 

Source Link

Document

Draw the specified circle using the specified paint.

Usage

From source file:br.com.mauker.materialseekbar.PinView.java

@Override
public void draw(Canvas canvas) {

    //Draw pin if pressed
    if (mPinRadiusPx > 0 && (mHasBeenPressed || !mIsTemporary)) {
        //            mBounds.set(
        //                    (int) mX - mPinRadiusPx,
        //                    (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding,
        //                    (int) mX + mPinRadiusPx,
        //                    (int) mY - (int) mPinPadding
        //            );

        mBounds.set((int) mX - mPinRadiusPx, (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding,
                (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding);

        mPin.setBounds(mBounds);/* w w w .  ja v  a  2s  .c o m*/
        String text = mValue;

        calibrateTextSize(mTextPaint, text, mBounds.width());
        mTextPaint.getTextBounds(text, 0, text.length(), mBounds);
        mTextPaint.setTextAlign(Paint.Align.CENTER);
        mPin.setColorFilter(mPinFilter);
        mPin.draw(canvas);
        canvas.drawText(text, mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding, mTextPaint);
    } else {
        canvas.drawCircle(mX, mY, mCircleRadiusPx, mCirclePaint);
    }
    super.draw(canvas);
}

From source file:com.tct.mail.utils.NotificationUtils.java

/**
 * Crop a square bitmap into a circular one. Used for both contact photos and letter tiles.
 * @param icon Square bitmap to crop/*w  w w  .  j a  v a2s .  co m*/
 * @return Circular bitmap
 */
private static Bitmap cropSquareIconToCircle(Bitmap icon) {
    final int iconWidth = icon.getWidth();
    final Bitmap newIcon = Bitmap.createBitmap(iconWidth, iconWidth, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(newIcon);
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, icon.getWidth(), icon.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(iconWidth / 2, iconWidth / 2, iconWidth / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(icon, rect, rect, paint);

    return newIcon;
}

From source file:com.achep.acdisplay.ui.widgets.CircleView.java

@Override
protected void onDraw(Canvas canvas) {
    final float ratio = calculateRatio();

    // Draw all corners
    drawCornerIcon(canvas, mDrawableLeftTopCorner, 0, 0 /* left top */);
    drawCornerIcon(canvas, mDrawableRightTopCorner, 1, 0 /* right top */);
    drawCornerIcon(canvas, mDrawableLeftBottomCorner, 0, 1 /* left bottom */);
    drawCornerIcon(canvas, mDrawableRightBottomCorner, 1, 1 /* right bottom */);

    // Darkening background
    int alpha = (int) (mDarkening * 255);
    alpha += (int) ((255 - alpha) * ratio * 0.7f); // Change alpha dynamically
    canvas.drawColor(/* w  ww .  j a  va 2 s . c o  m*/
            Color.argb(alpha, Color.red(mOuterColor), Color.green(mOuterColor), Color.blue(mOuterColor)));

    // Draw unlock circle
    mPaint.setColor(mInnerColor);
    mPaint.setAlpha((int) (255 * Math.pow(ratio, 1f / 3f)));
    canvas.drawCircle(mPoint[0], mPoint[1], mRadiusDrawn, mPaint);

    if (ratio >= 0.5f) {
        // Draw unlock icon at the center of circle
        float scale = 0.5f + 0.5f * ratio;
        canvas.save();
        canvas.translate(mPoint[0] - mDrawable.getMinimumWidth() / 2 * scale,
                mPoint[1] - mDrawable.getMinimumHeight() / 2 * scale);
        canvas.scale(scale, scale);
        mDrawable.draw(canvas);
        canvas.restore();
    }
}

From source file:com.tbse.mywearapplication.WatchFaceDrawer.java

void onDraw(Context context, IWatchFaceConfig config, Canvas canvas, Rect bounds) {
    final Calendar calendar = config.getCalendar();
    final boolean isAmbient = config.isAmbient();
    final boolean isRound = config.isRound();
    final boolean useLightTheme = !isAmbient && config.isLightTheme();

    mBackgroundPaint.setColor(ContextCompat.getColor(context,
            useLightTheme ? R.color.watchface_background_light : R.color.watchface_background));

    /////////////////////////////////////////////////////////////////////
    // Draw your watch face here, using the provided canvas and bounds //
    /////////////////////////////////////////////////////////////////////

    final int width = bounds.width();
    final int height = bounds.height();

    // Find the center. Ignore the window insets so that, on round
    // watches with a "chin", the watch face is centered on the entire
    // screen, not just the usable portion.
    final float centerX = width / 2f;
    final float centerY = height / 2f;

    // Draw the background.
    if (mIsMobilePreview) {
        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mPreviewBorderPaint);
        } else {/*from   www.  ja  v a 2s. co  m*/
            final float radius = mPreviewSquareRadius;
            final RectF rectF = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
            canvas.drawRoundRect(rectF, radius, radius, mPreviewBorderPaint);
        }

        final float translateXY = width * 0.05f;
        canvas.translate(translateXY, translateXY);
        canvas.scale(0.9f, 0.9f);

        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mBackgroundPaint);
        } else {
            canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
        }
    } else {
        canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
    }

    // Draw weather icon
    if (image != null) {
        Matrix matrix = new Matrix();
        matrix.setTranslate(50, 90);
        matrix.preScale(0.2f, 0.2f);
        canvas.drawBitmap(image, matrix, null);
    }

    final float secRot = calendar.get(Calendar.SECOND) / 30f * (float) Math.PI;
    final int minutes = calendar.get(Calendar.MINUTE);
    final float minRot = minutes / 30f * (float) Math.PI;
    final float hrRot = ((calendar.get(Calendar.HOUR) + (minutes / 60f)) / 6f) * (float) Math.PI;

    final float secLength = centerX - mSecondOuterOffset;
    final float minLength = centerX - mMinuteOuterOffset;
    final float hrLength = centerX - mHourOuterOffset;

    if (!isAmbient) {
        final float secX = (float) Math.sin(secRot) * secLength;
        final float secY = (float) -Math.cos(secRot) * secLength;
        canvas.drawLine(centerX, centerY, centerX + secX, centerY + secY, mSecondHandPaint);
    }

    final float minX = (float) Math.sin(minRot) * minLength;
    final float minY = (float) -Math.cos(minRot) * minLength;
    canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mMinuteHandPaint);

    final float hrX = (float) Math.sin(hrRot) * hrLength;
    final float hrY = (float) -Math.cos(hrRot) * hrLength;
    canvas.drawLine(centerX, centerY, centerX + hrX, centerY + hrY, mHourHandPaint);

    // Draw weather text
    canvas.drawText(day, 50, 50, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(low, 50, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(high, 80, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(weatherDescription, 50, 80, isAmbient ? ambientTextPaint : textPaint);

}

From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java

@NonNull
private Bitmap buildMarkerBitmap(@NonNull Context c) {
    // Oh, this is going to be FUN.
    int dim = c.getResources().getDimensionPixelSize(R.dimen.known_location_marker_canvas_size);
    float radius = c.getResources().getDimension(R.dimen.known_location_pin_head_radius);

    Bitmap bitmap = Bitmap.createBitmap(dim, dim, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Paint paint = new Paint();
    paint.setAntiAlias(true);/*from  w  w w . j  av a 2  s  .c  o  m*/

    KnownLocationPinData pinData = new KnownLocationPinData(c, mLocation);

    // Draw the pin line first.  That goes from the bottom-center up to
    // wherever the radius and length take us.
    float topX = Double.valueOf((dim / 2) + (pinData.getLength() * Math.cos(pinData.getAngle()))).floatValue();
    float topY = Double.valueOf(dim - (pinData.getLength() * Math.sin(pinData.getAngle()))).floatValue();
    paint.setStrokeWidth(c.getResources().getDimension(R.dimen.known_location_stroke));
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.BLACK);

    canvas.drawLine(dim / 2, dim, topX, topY, paint);

    // On the top of that line, fill in a circle.
    paint.setColor(pinData.getColor());
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(topX, topY, radius, paint);

    // And outline it.
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawCircle(topX, topY, radius, paint);

    return bitmap;
}

From source file:com.plugin.weight.ripple.RippleLayoutView.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    if (animationRunning) {
        canvas.save();/*from   ww w  .  ja va  2s  .c  o  m*/
        if (rippleDuration <= timer * frameRate) {
            animationRunning = false;
            timer = 0;
            durationEmpty = -1;
            timerEmpty = 0;
            // There is problem on Android M where canvas.restore() seems to be called automatically
            // For now, don't call canvas.restore() manually on Android M (API 23)
            if (Build.VERSION.SDK_INT != 23) {
                canvas.restore();
            }
            invalidate();
            if (onCompletionListener != null)
                onCompletionListener.onComplete(this);
            return;
        } else
            canvasHandler.postDelayed(runnable, frameRate);

        if (timer == 0)
            canvas.save();

        canvas.drawCircle(x, y, (radiusMax * (((float) timer * frameRate) / rippleDuration)), paint);

        paint.setColor(Color.parseColor("#ffff4444"));

        if (rippleType == 1 && originBitmap != null && (((float) timer * frameRate) / rippleDuration) > 0.4f) {
            if (durationEmpty == -1)
                durationEmpty = rippleDuration - timer * frameRate;

            timerEmpty++;
            final Bitmap tmpBitmap = getCircleBitmap(
                    (int) ((radiusMax) * (((float) timerEmpty * frameRate) / (durationEmpty))));
            canvas.drawBitmap(tmpBitmap, 0, 0, paint);
            tmpBitmap.recycle();
        }

        paint.setColor(rippleColor);

        if (rippleType == 1) {
            if ((((float) timer * frameRate) / rippleDuration) > 0.6f)
                paint.setAlpha((int) (rippleAlpha
                        - ((rippleAlpha) * (((float) timerEmpty * frameRate) / (durationEmpty)))));
            else
                paint.setAlpha(rippleAlpha);
        } else
            paint.setAlpha(
                    (int) (rippleAlpha - ((rippleAlpha) * (((float) timer * frameRate) / rippleDuration))));

        timer++;
    }
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

private void drawCenter(Canvas canvas, float alphaMod) {
    mPaintCenter.setAlpha((int) (255 * alphaMod + 0.5f));
    canvas.drawCircle(mXCenter, mYCenter, mCenterDotRadius, mPaintCenter);
}

From source file:im.neon.util.NotificationUtils.java

/**
 * Build a message notification./* w  ww  .j  a v a  2  s .  co  m*/
 * @param context the context
 * @param from the sender
 * @param matrixId the user account id;
 * @param displayMatrixId true to display the matrix id
 * @param largeIcon the notification icon
 * @param unseenNotifiedRoomsCount the number of notified rooms
 * @param body the message body
 * @param roomId the room id
 * @param roomName the room name
 * @param shouldPlaySound true when the notification as sound.
 * @param isInvitationEvent true if it is an invitation notification
 * @return the notification
 */
public static Notification buildMessageNotification(Context context, String from, String matrixId,
        boolean displayMatrixId, Bitmap largeIcon, int unseenNotifiedRoomsCount, String body, String roomId,
        String roomName, boolean shouldPlaySound, boolean isInvitationEvent) {

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setWhen(System.currentTimeMillis());

    if (!TextUtils.isEmpty(from)) {
        // don't display the room name for 1:1 room notifications.
        if (!TextUtils.isEmpty(roomName) && !roomName.equals(from)) {
            builder.setContentTitle(from + " (" + roomName + ")");
        } else {
            builder.setContentTitle(from);
        }
    } else {
        builder.setContentTitle(roomName);
    }

    builder.setContentText(body);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.drawable.message_notification_transparent);

    if (null != largeIcon) {
        largeIcon = createSquareBitmap(largeIcon);

        // add a bubble in the top right
        if (0 != unseenNotifiedRoomsCount) {
            try {
                android.graphics.Bitmap.Config bitmapConfig = largeIcon.getConfig();

                // set default bitmap config if none
                if (bitmapConfig == null) {
                    bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
                }

                // setLargeIcon must used a 64 * 64 pixels bitmap
                // rescale to have the same text UI.
                float densityScale = context.getResources().getDisplayMetrics().density;
                int side = (int) (64 * densityScale);

                Bitmap bitmapCopy = Bitmap.createBitmap(side, side, bitmapConfig);
                Canvas canvas = new Canvas(bitmapCopy);

                // resize the bitmap to fill in size
                int bitmapWidth = largeIcon.getWidth();
                int bitmapHeight = largeIcon.getHeight();

                float scale = Math.min((float) canvas.getWidth() / (float) bitmapWidth,
                        (float) canvas.getHeight() / (float) bitmapHeight);

                int scaledWidth = (int) (bitmapWidth * scale);
                int scaledHeight = (int) (bitmapHeight * scale);

                Bitmap rescaledBitmap = Bitmap.createScaledBitmap(largeIcon, scaledWidth, scaledHeight, true);
                canvas.drawBitmap(rescaledBitmap, (side - scaledWidth) / 2, (side - scaledHeight) / 2, null);

                String text = "" + unseenNotifiedRoomsCount;

                // prepare the text drawing
                Paint textPaint = new Paint();
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
                textPaint.setColor(Color.WHITE);
                textPaint.setTextSize(10 * densityScale);

                // get its size
                Rect textBounds = new Rect();

                if (-1 == mUnreadBubbleWidth) {
                    textPaint.getTextBounds("99", 0, 2, textBounds);
                    mUnreadBubbleWidth = textBounds.width();
                }

                textPaint.getTextBounds(text, 0, text.length(), textBounds);

                // draw a red circle
                int radius = mUnreadBubbleWidth;
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                paint.setColor(Color.RED);
                canvas.drawCircle(canvas.getWidth() - radius, radius, radius, paint);

                // draw the text
                canvas.drawText(text,
                        canvas.getWidth() - textBounds.width() - (radius - (textBounds.width() / 2)),
                        -textBounds.top + (radius - (-textBounds.top / 2)), textPaint);

                // get the new bitmap
                largeIcon = bitmapCopy;
            } catch (Exception e) {
                Log.e(LOG_TAG, "## buildMessageNotification(): Exception Msg=" + e.getMessage());
            }
        }

        builder.setLargeIcon(largeIcon);
    }

    String name = ": ";
    if (!TextUtils.isEmpty(roomName)) {
        name = " (" + roomName + "): ";
    }

    if (displayMatrixId) {
        from = "[" + matrixId + "]\n" + from;
    }

    builder.setTicker(from + name + body);

    TaskStackBuilder stackBuilder;
    Intent intent;

    intent = new Intent(context, VectorRoomActivity.class);
    intent.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);

    if (null != matrixId) {
        intent.putExtra(VectorRoomActivity.EXTRA_MATRIX_ID, matrixId);
    }

    stackBuilder = TaskStackBuilder.create(context).addParentStack(VectorRoomActivity.class)
            .addNextIntent(intent);

    // android 4.3 issue
    // use a generator for the private requestCode.
    // When using 0, the intent is not created/launched when the user taps on the notification.
    //
    PendingIntent pendingIntent = stackBuilder.getPendingIntent((new Random()).nextInt(1000),
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    // display the message with more than 1 lines when the device supports it
    NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
    textStyle.bigText(from + ":" + body);
    builder.setStyle(textStyle);

    // do not offer to quick respond if the user did not dismiss the previous one
    if (!LockScreenActivity.isDisplayingALockScreenActivity()) {
        if (!isInvitationEvent) {
            // offer to type a quick answer (i.e. without launching the application)
            Intent quickReplyIntent = new Intent(context, LockScreenActivity.class);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_ROOM_ID, roomId);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_SENDER_NAME, from);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MESSAGE_BODY, body);

            if (null != matrixId) {
                quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MATRIX_ID, matrixId);
            }

            // the action must be unique else the parameters are ignored
            quickReplyIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, quickReplyIntent, 0);
            builder.addAction(R.drawable.vector_notification_quick_reply,
                    context.getString(R.string.action_quick_reply), pIntent);
        } else {
            {
                // offer to type a quick reject button
                Intent leaveIntent = new Intent(context, JoinScreenActivity.class);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_REJECT, true);

                // the action must be unique else the parameters are ignored
                leaveIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, leaveIntent, 0);
                builder.addAction(R.drawable.vector_notification_reject_invitation,
                        context.getString(R.string.reject), pIntent);
            }

            {
                // offer to type a quick accept button
                Intent acceptIntent = new Intent(context, JoinScreenActivity.class);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_JOIN, true);

                // the action must be unique else the parameters are ignored
                acceptIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, acceptIntent, 0);
                builder.addAction(R.drawable.vector_notification_accept_invitation,
                        context.getString(R.string.join), pIntent);
            }
        }

        // Build the pending intent for when the notification is clicked
        Intent roomIntentTap;
        if (isInvitationEvent) {
            // for invitation the room preview must be displayed
            roomIntentTap = CommonActivityUtils.buildIntentPreviewRoom(matrixId, roomId, context,
                    VectorFakeRoomPreviewActivity.class);
        } else {
            roomIntentTap = new Intent(context, VectorRoomActivity.class);
            roomIntentTap.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);
        }
        // the action must be unique else the parameters are ignored
        roomIntentTap.setAction(TAP_TO_VIEW_ACTION + ((int) (System.currentTimeMillis())));

        // Recreate the back stack
        TaskStackBuilder stackBuilderTap = TaskStackBuilder.create(context)
                .addParentStack(VectorRoomActivity.class).addNextIntent(roomIntentTap);

        builder.addAction(R.drawable.vector_notification_open, context.getString(R.string.action_open),
                stackBuilderTap.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
    }

    //extendForCar(context, builder, roomId, roomName, from, body);

    Notification n = builder.build();
    n.flags |= Notification.FLAG_SHOW_LIGHTS;
    n.defaults |= Notification.DEFAULT_LIGHTS;

    if (shouldPlaySound) {
        n.defaults |= Notification.DEFAULT_SOUND;
    }

    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // some devices crash if this field is not set
        // even if it is deprecated

        // setLatestEventInfo() is deprecated on Android M, so we try to use
        // reflection at runtime, to avoid compiler error: "Cannot resolve method.."
        try {
            Method deprecatedMethod = n.getClass().getMethod("setLatestEventInfo", Context.class,
                    CharSequence.class, CharSequence.class, PendingIntent.class);
            deprecatedMethod.invoke(n, context, from, body, pendingIntent);
        } catch (Exception ex) {
            Log.e(LOG_TAG,
                    "## buildMessageNotification(): Exception - setLatestEventInfo() Msg=" + ex.getMessage());
        }
    }

    return n;
}

From source file:com.wabao.android.app.widget.CirclePageIndicator.java

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

    if (mViewPager == null) {
        return;/*from  w ww  .j a  va 2 s .c o m*/
    }
    final int count = mViewPager.getAdapter().getCount();
    if (count == 0) {
        return;
    }

    if (mCurrentPage >= count) {
        setCurrentItem(count - 1);
        return;
    }

    final float indicatorWidth = (count * mGapWidth) - mGapWidth;
    final float paddingTop = getPaddingTop();
    final float paddingLeft = getPaddingLeft();
    final float paddingRight = getPaddingRight();

    float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f);
    float horizontalOffset = paddingLeft;
    if (mCentered) {
        horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f);
    }

    // Draw stroked circles
    for (int i = 0; i < count; i++) {
        float dx1 = horizontalOffset + (i * mGapWidth);
        canvas.drawCircle(dx1, verticalOffset, 10, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected);
    }
}

From source file:org.getlantern.firetweet.view.ShapedImageView.java

private void drawBorder(@NonNull final Canvas canvas, @NonNull final RectF dest) {
    if (mBorderColors == null)
        return;//from   w  w  w.ja  va  2  s.co  m
    final RectF transitionSrc = mTransitionSource, transitionDst = mTransitionDestination;
    final float strokeWidth;
    if (transitionSrc != null && transitionDst != null) {
        final float progress = 1
                - (dest.width() - transitionDst.width()) / (transitionSrc.width() - transitionDst.width());
        strokeWidth = mStrokeWidth * progress;
        mBorderPaint.setAlpha(Math.round(mBorderAlpha * progress));
        ViewCompat.setTranslationZ(this, -ViewCompat.getElevation(this) * (1 - progress));
    } else {
        strokeWidth = mStrokeWidth;
        mBorderPaint.setAlpha(mBorderAlpha);
        ViewCompat.setTranslationZ(this, 0);
    }
    mBorderPaint.setStrokeWidth(strokeWidth);
    if (getStyle() == SHAPE_CIRCLE) {
        final float circleRadius = Math.min(dest.width(), dest.height()) / 2f - strokeWidth / 2;
        canvas.drawCircle(dest.centerX(), dest.centerY(), circleRadius, mBorderPaint);
    } else {
        final float radius = getCalculatedCornerRadius();
        final float inset = mStrokeWidth / 2;
        dest.inset(inset, inset);
        canvas.drawRoundRect(dest, radius, radius, mBorderPaint);
        dest.inset(-inset, -inset);
    }
}