本文整理了Java中android.graphics.Path.offset()
方法的一些代码示例,展示了Path.offset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.offset()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:offset
暂无
代码示例来源:origin: siyamed/android-shape-imageview
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;
}
代码示例来源:origin: mikepenz/Android-Iconics
/**
* 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);
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void offset(float dx, float dy, Path dst) {
if (dst != null) {
dst.set(realObject);
} else {
dst = realObject;
}
dst.offset(dx, dy);
}
代码示例来源:origin: scwang90/SmartRefreshLayout
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);
}
}
代码示例来源:origin: airbnb/lottie-android
path.offset(position.x, position.y);
path.close();
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
@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);
}
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
@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);
}
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
@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);
}
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
@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);
}
代码示例来源:origin: JorgeCastilloPrz/AndroidFillableLoaders
@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);
}
代码示例来源:origin: smuyyh/BookReader
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);
}
}
代码示例来源:origin: airbnb/lottie-android
path.offset(position.x, position.y);
path.close();
代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout
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);
}
}
代码示例来源:origin: siyamed/android-shape-imageview
pathMatrix.postTranslate(translateX, translateY);
shapePath.transform(pathMatrix, path);
path.offset(borderWidth, borderWidth);
代码示例来源:origin: ZieIony/Carbon
path.offset(e, e);
shadowCanvas.scale(1 / scale, 1 / scale);
shadowCanvas.drawPath(path, paint);
代码示例来源:origin: airbnb/lottie-android
path.offset(position.x, position.y);
代码示例来源:origin: code-mc/loadtoast
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);
}
}
代码示例来源:origin: huxq17/XRefreshView
mArrow.lineTo((mArrowWidth * mArrowScale / 2),
(mArrowHeight * mArrowScale));
mArrow.offset(x - inset, y);
mArrow.close();
代码示例来源:origin: weexteam/weex-hackernews
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);
}
}
代码示例来源:origin: chenyangcun/MaterialDesignExample
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!