@Override public void draw(Canvas canvas) { canvas.drawOval(mRectF, mPaint); }
@Override protected void clearArea(Canvas canvas, RectF cropBounds, Paint clearPaint) { canvas.drawOval(cropBounds, clearPaint); }
private void fillCircle(Canvas canvas, float x, float y, float radius, int color, boolean transparent){ if(transparent) return; mFillPaint.setColor(color); mRect.set(x - radius, y - radius, x + radius, y + radius); canvas.drawOval(mRect, mFillPaint); }
private void drawCircle(Canvas canvas) { outlinePaint.setStrokeWidth(1); canvas.drawOval(new RectF(drawRect), outlinePaint); }
@Override protected void drawBorders(Canvas canvas, RectF cropBounds, Paint paint) { canvas.drawOval(cropBounds, paint); if (overlayConfig.isDynamicCrop()) { canvas.drawRect(cropBounds, paint); } }
@Override protected 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(mTranslationOffset, mTranslationOffset); // Draw the color wheel. canvas.drawOval(mColorWheelRectangle, mColorWheelPaint); float[] pointerPosition = calculatePointerPosition(mAngle); // Draw the pointer's "halo" canvas.drawCircle(pointerPosition[0], pointerPosition[1], mPointerRadius, mPointerHaloPaint); // Draw the pointer (the currently selected color) slightly smaller on top. canvas.drawCircle(pointerPosition[0], pointerPosition[1], (float) (mPointerRadius / 1.2), mPointerColor); }
private void drawBorder(Canvas canvas) { RectF rect = new RectF(getBounds()); rect.inset(borderThickness / 2, borderThickness / 2); if (shape instanceof OvalShape) { canvas.drawOval(rect, borderPaint); } else if (shape instanceof RoundRectShape) { canvas.drawRoundRect(rect, radius, radius, borderPaint); } else { canvas.drawRect(rect, borderPaint); } }
/** * Create a new bitmap that has all pixels beyond the oval shape transparent. Old bitmap is * recycled. */ public static Bitmap toOvalBitmap(@NonNull Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); int color = 0xff424242; Paint paint = new Paint(); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); RectF rect = new RectF(0, 0, width, height); canvas.drawOval(rect, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, 0, 0, paint); bitmap.recycle(); return output; }
mBallRadius * (i * 2) + mBallSideOffsets, mHeight); mPaint.setAlpha(OVAL_ALPHA); canvas.drawOval(mOvalRect, mPaint); mHeight - mOvalVerticalRadius + mOvalVerticalRadius * mLeftOvalShapeRate); mPaint.setAlpha(OVAL_ALPHA); canvas.drawOval(mOvalRect, mPaint); mHeight - mOvalVerticalRadius + mOvalVerticalRadius * mRightOvalShapeRate); mPaint.setAlpha(OVAL_ALPHA); canvas.drawOval(mOvalRect, mPaint);
@Override protected void draw(Canvas canvas, Rect bounds) { int saveCount = canvas.save(); RectF arcBounds = mTempBounds; arcBounds.set(bounds); mPaint.setColor(mColor); mPaint.setStyle(Paint.Style.STROKE); canvas.drawPath(createLeftEyeCircle(arcBounds, mLeftEyeCircleOffsetY), mPaint); canvas.drawPath(createRightEyeCircle(arcBounds, mRightEyeCircleOffsetY), mPaint); mPaint.setStyle(Paint.Style.FILL); //create left eye ball canvas.drawOval(createLeftEyeBall(arcBounds, mLeftEyeBallOffsetY), mPaint); //create right eye ball canvas.drawOval(createRightEyeBall(arcBounds, mRightEyeBallOffsetY), mPaint); canvas.restoreToCount(saveCount); }
@Override public void draw(Canvas canvas) { if(mNeedBuildShadow){ buildShadow(); mNeedBuildShadow = false; } int saveCount; if(mShadowSize > 0){ saveCount = canvas.save(); canvas.translate(mShadowSize + mRadius, mShadowSize + mRadius + mShadowOffset); canvas.drawPath(mShadowPath, mShadowPaint); canvas.restoreToCount(saveCount); } saveCount = canvas.save(); canvas.translate(mShadowSize + mRadius, mShadowSize + mRadius); if(mShadowSize > 0) canvas.drawPath(mGlowPath, mGlowPaint); mTempRect.set(-mRadius, -mRadius, mRadius, mRadius); if(!isRunning()) mPaint.setColor(mCurColor); else mPaint.setColor(ColorUtil.getMiddleColor(mPrevColor, mCurColor, mAnimProgress)); canvas.drawOval(mTempRect, mPaint); canvas.restoreToCount(saveCount); }
POINT_X[i] + mDanceBallRadius + mShapeChangeWidth / 2.0f, POINT_Y[i] + mDanceBallRadius + mShapeChangeHeight / 2.0f); canvas.drawOval(rectF, mPaint); canvas.rotate(-i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
/** * Custom oval shape */ @Override protected void drawBlurredBitmap(Canvas canvas, Bitmap blurredBitmap, int overlayColor) { if (blurredBitmap != null) { mRectF.right = getWidth(); mRectF.bottom = getHeight(); mPaint.reset(); mPaint.setAntiAlias(true); BitmapShader shader = new BitmapShader(blurredBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); Matrix matrix = new Matrix(); matrix.postScale(mRectF.width() / blurredBitmap.getWidth(), mRectF.height() / blurredBitmap.getHeight()); shader.setLocalMatrix(matrix); mPaint.setShader(shader); canvas.drawOval(mRectF, mPaint); mPaint.reset(); mPaint.setAntiAlias(true); mPaint.setColor(overlayColor); canvas.drawOval(mRectF, mPaint); } } }
/** Draw borders of the crop area. */ private void drawBorders(Canvas canvas) { if (mBorderPaint != null) { float w = mBorderPaint.getStrokeWidth(); RectF rect = mCropWindowHandler.getRect(); rect.inset(w / 2, w / 2); if (mCropShape == CropImageView.CropShape.RECTANGLE) { // Draw rectangle crop window border. canvas.drawRect(rect, mBorderPaint); } else { // Draw circular crop window border canvas.drawOval(rect, mBorderPaint); } } }
@Test public void getOvalHistoryCount_shouldReturnTotalNumberOfDrawOvalEvents() throws Exception { Canvas canvas = new Canvas(); canvas.drawOval(new RectF(), new Paint()); canvas.drawOval(new RectF(), new Paint()); ShadowCanvas shadowCanvas = shadowOf(canvas); assertThat(shadowCanvas.getOvalPaintHistoryCount()).isEqualTo(2); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mChangeBackgroundMode) { int width = getWidth(); int height = getHeight(); Iterator<Oval> iterator = mOvals.iterator(); while (iterator.hasNext()) { Oval oval = iterator.next(); mPaint.setColor(oval.color); if (oval.r < oval.maxR) { mTempRectF.set(oval.getLeft(), oval.getTop(), oval.getRight(), oval.getBottom()); canvas.drawOval(mTempRectF, mPaint); } else { this.setBackgroundColor(oval.color); canvas.drawRect(0, 0, width, height, mPaint); iterator.remove(); } invalidate(); } } }
private void drawHighlights(Canvas canvas) { List<HighLight> highLights = guidePage.getHighLights(); if (highLights != null) { for (HighLight highLight : highLights) { RectF rectF = highLight.getRectF((ViewGroup) getParent()); switch (highLight.getShape()) { case CIRCLE: canvas.drawCircle(rectF.centerX(), rectF.centerY(), highLight.getRadius(), mPaint); break; case OVAL: canvas.drawOval(rectF, mPaint); break; case ROUND_RECTANGLE: canvas.drawRoundRect(rectF, highLight.getRound(), highLight.getRound(), mPaint); break; case RECTANGLE: default: canvas.drawRect(rectF, mPaint); break; } notifyDrewListener(canvas, highLight, rectF); } } }
@Test public void drawOval_shouldRecordOvalHistoryEvents() throws Exception { Canvas canvas = new Canvas(); RectF oval0 = new RectF(); RectF oval1 = new RectF(); Paint paint0 = new Paint(); paint0.setColor(Color.RED); Paint paint1 = new Paint(); paint1.setColor(Color.WHITE); canvas.drawOval(oval0, paint0); canvas.drawOval(oval1, paint1); ShadowCanvas shadowCanvas = shadowOf(canvas); assertThat(shadowCanvas.getDrawnOval(0).oval).isEqualTo(oval0); assertThat(shadowCanvas.getDrawnOval(0).paint.getColor()).isEqualTo(Color.RED); assertThat(shadowCanvas.getDrawnOval(1).oval).isEqualTo(oval1); assertThat(shadowCanvas.getDrawnOval(1).paint.getColor()).isEqualTo(Color.WHITE); }
/** * Draws the face annotations for position, size, and ID on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = mFace; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. float cx = translateX(face.getPosition().x + face.getWidth() / 2); float cy = translateY(face.getPosition().y + face.getHeight() / 2); canvas.drawCircle(cx, cy, FACE_POSITION_RADIUS, mFacePositionPaint); canvas.drawText("id: " + getId(), cx + ID_X_OFFSET, cy + ID_Y_OFFSET, mIdPaint); // Draws an oval around the face. float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = cx - xOffset; float top = cy - yOffset; float right = cx + xOffset; float bottom = cy + yOffset; canvas.drawOval(left, top, right, bottom, mBoxPaint); } }