PathInfo(Path path, float width, float height) { this.path = path; float tmpWidth = width; float tmpHeight = height; RectF bounds = new RectF(); path.computeBounds(bounds, true); if(width <= 0 && height <= 0) { tmpWidth = (float) Math.ceil(bounds.width()); tmpHeight = (float) Math.ceil(bounds.height()); path.offset(-1 * (float) Math.floor(bounds.left), -1 * (float) Math.round(bounds.top)); } this.width = tmpWidth; this.height = tmpHeight; }
/** * Set the icon offset */ private void offsetIcon(@NonNull Rect viewBounds) { float startX = viewBounds.centerX() - (mPathBounds.width() / 2); float offsetX = startX - mPathBounds.left; float startY = viewBounds.centerY() - (mPathBounds.height() / 2); float offsetY = startY - (mPathBounds.top); mPath.offset(offsetX + mIconOffsetX, offsetY + mIconOffsetY); }
@Implementation protected void offset(float dx, float dy, Path dst) { if (dst != null) { dst.set(realObject); } else { dst = realObject; } dst.offset(dx, dy); }
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float inset = (int) mStrokeInset / 2 * mArrowScale; float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo(mArrowWidth * mArrowScale, 0); mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mCurrentColor); c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
path.offset(position.x, position.y); path.close();
@Override public void transform(Canvas canvas, float currentFillPhase, View view) { cacheDimensions(view.getWidth(), view.getHeight()); buildClippingPath(); wavesPath.offset(0, height * -currentFillPhase); canvas.clipPath(wavesPath, Region.Op.DIFFERENCE); }
@Override public void transform(Canvas canvas, float currentFillPhase, View view) { cacheDimensions(view.getWidth(), view.getHeight()); buildClippingPath(); roundedPath.offset(0, height * -currentFillPhase); canvas.clipPath(roundedPath, Region.Op.DIFFERENCE); }
@Override public void transform(Canvas canvas, float currentFillPhase, View view) { cacheDimensions(view.getWidth(), view.getHeight()); buildClippingPath(); spikesPath.offset(0, height * -currentFillPhase); canvas.clipPath(spikesPath, Region.Op.DIFFERENCE); }
@Override public void transform(Canvas canvas, float currentFillPhase, View view) { cacheDimensions(view.getWidth(), view.getHeight()); Path path = buildClippingPath(); path.offset(0, height * -currentFillPhase); canvas.clipPath(path, Region.Op.DIFFERENCE); }
@Override public void transform(Canvas canvas, float currentFillPhase, View view) { cacheDimensions(view.getWidth(), view.getHeight()); Path path = buildClippingPath(); path.offset(0, height * -currentFillPhase); canvas.clipPath(path, Region.Op.DIFFERENCE); }
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float inset = (int) mStrokeInset / 2 * mArrowScale; float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo(mArrowWidth * mArrowScale, 0); mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mCurrentColor); c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
path.offset(position.x, position.y); path.close();
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo((mArrowWidth) * mArrowScale, 0); mArrow.lineTo(((mArrowWidth) * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x-((mArrowWidth) * mArrowScale / 2), y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mColors[mColorIndex]); //when sweepAngle < 0 adjust the position of the arrow c.rotate(startAngle + (sweepAngle<0?0:sweepAngle) - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
pathMatrix.postTranslate(translateX, translateY); shapePath.transform(pathMatrix, path); path.offset(borderWidth, borderWidth);
path.offset(e, e); shadowCanvas.scale(1 / scale, 1 / scale); shadowCanvas.drawPath(path, paint);
path.offset(position.x, position.y);
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo((mArrowWidth) * mArrowScale, 0); mArrow.lineTo(((mArrowWidth) * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x-((mArrowWidth) * mArrowScale / 2), y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mColors[mColorIndex]); //when sweepAngle < 0 adjust the position of the arrow c.rotate(startAngle + (sweepAngle<0?0:sweepAngle) - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close();
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new Path(); mArrow.setFillType(Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float inset = (int) mStrokeInset / 2 * mArrowScale; float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo(mArrowWidth * mArrowScale, 0); mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mCurrentColor); c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mShowArrow) { if (mArrow == null) { mArrow = new android.graphics.Path(); mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD); } else { mArrow.reset(); } // Adjust the position of the triangle so that it is inset as // much as the arc, but also centered on the arc. float inset = (int) mStrokeInset / 2 * mArrowScale; float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX()); float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY()); // Update the path each time. This works around an issue in SKIA // where concatenating a rotation matrix to a scale matrix // ignored a starting negative rotation. This appears to have // been fixed as of API 21. mArrow.moveTo(0, 0); mArrow.lineTo(mArrowWidth * mArrowScale, 0); mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight * mArrowScale)); mArrow.offset(x - inset, y); mArrow.close(); // draw a triangle mArrowPaint.setColor(mCurrentColor); c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(), bounds.exactCenterY()); c.drawPath(mArrow, mArrowPaint); } }