本文整理了Java中android.graphics.Path.reset()
方法的一些代码示例,展示了Path.reset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.reset()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:reset
暂无
代码示例来源:origin: square/leakcanary
private static void squigglyHorizontalPath(Path path, float left, float right, float centerY,
float amplitude,
float periodDegrees) {
path.reset();
float y;
path.moveTo(left, centerY);
float period = (float) (2 * Math.PI / periodDegrees);
for (float x = 0; x <= right - left; x += 1) {
y = (float) (amplitude * Math.sin(40 + period * x) + centerY);
path.lineTo(left + x, y);
}
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
protected void drawWave(Canvas canvas, int width) {
//重置画笔
mPath.reset();
//绘制贝塞尔曲线
mPath.lineTo(0, mWaveTop);
mPath.quadTo(mWaveOffsetX >= 0 ? (mWaveOffsetX) : width / 2, mWaveTop + mWaveHeight, width, mWaveTop);
mPath.lineTo(width, 0);
mPaint.setColor(mPrimaryColor);
canvas.drawPath(mPath, mPaint);
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@NonNull
private Path generateClipPath(BoxBody body, int width) {
mPath.reset();
mPath.lineTo(0, body.boxCenterTop);
mPath.lineTo(body.boxLeft, body.boxCenterTop);
mPath.lineTo(body.boxCenterX, body.boxCenterY);
mPath.lineTo(body.boxRight, body.boxCenterTop);
mPath.lineTo(width, body.boxCenterTop);
mPath.lineTo(width, 0);
mPath.close();
return mPath;
}
代码示例来源:origin: scwang90/SmartRefreshLayout
private void drawSpringUp(Canvas canvas, int viewWidth) {
if (mSpringRatio > 0) {
float leftX = (viewWidth / 2 - 4 * mBollRadius + mSpringRatio * 3 * mBollRadius);
if (mSpringRatio < 0.9) {
mPath.reset();
mPath.moveTo(leftX, mBollY);
mPath.quadTo(viewWidth / 2, mBollY - mBollRadius * mSpringRatio * 2,
viewWidth - leftX, mBollY);
canvas.drawPath(mPath, mFrontPaint);
} else {
canvas.drawCircle(viewWidth / 2, mBollY, mBollRadius, mFrontPaint);
}
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
private void drawWave(Canvas canvas, int viewWidth, int viewHeight) {
float baseHeight = Math.min(mHeadHeight, viewHeight);
if (mWaveHeight != 0) {
mPath.reset();
mPath.lineTo(viewWidth, 0);
mPath.lineTo(viewWidth, baseHeight);
mPath.quadTo(viewWidth / 2, baseHeight + mWaveHeight * 2, 0, baseHeight);
mPath.close();
canvas.drawPath(mPath, mBackPaint);
} else {
canvas.drawRect(0, 0, viewWidth, baseHeight, mBackPaint);
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
private void drawBollTail(Canvas canvas, int viewWidth, float fraction) {
if (mShowBollTail) {
final float bottom = mHeadHeight + mWaveHeight;
final float startY = mBollY + mBollRadius * fraction / 2;
final float startX = viewWidth / 2 + (float) Math.sqrt(mBollRadius * mBollRadius * (1 - fraction * fraction / 4));
final float bezier1x = (viewWidth / 2 + (mBollRadius * 3 / 4) * (1 - fraction));
final float bezier2x = bezier1x + mBollRadius;
mPath.reset();
mPath.moveTo(startX, startY);
mPath.quadTo(bezier1x, bottom, bezier2x, bottom);
mPath.lineTo(viewWidth - bezier2x, bottom);
mPath.quadTo(viewWidth - bezier1x, bottom, viewWidth - startX, startY);
canvas.drawPath(mPath, mFrontPaint);
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@NonNull
private Path generateBoxBodyPath(BoxBody body) {
mPath.reset();
mPath.moveTo(body.boxLeft, body.boxCenterBottom);
mPath.lineTo(body.boxCenterX, body.boxBottom);
mPath.lineTo(body.boxRight, body.boxCenterBottom);
mPath.quadTo(body.boxRight + body.boxSideLength / 2 * mReboundPercent, body.boxCenterY, body.boxRight, body.boxCenterTop);
mPath.lineTo(body.boxCenterX, body.boxTop);
mPath.lineTo(body.boxLeft, body.boxCenterTop);
mPath.quadTo(body.boxLeft - body.boxSideLength / 2 * mReboundPercent, body.boxCenterY, body.boxLeft, body.boxCenterBottom);
mPath.close();
return mPath;
}
//</editor-fold>
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
protected void dispatchDraw(Canvas canvas) {
if (mShowBezierWave) {
//重置画笔
mBezierPath.reset();
mBezierPath.lineTo(0, mHeadHeight);
//绘制贝塞尔曲线
final View thisView = this;
mBezierPath.quadTo(thisView.getMeasuredWidth() / 2, mHeadHeight + mWaveHeight * 1.9f, thisView.getMeasuredWidth(), mHeadHeight);
mBezierPath.lineTo(thisView.getMeasuredWidth(), 0);
canvas.drawPath(mBezierPath, mBezierPaint);
}
super.dispatchDraw(canvas);
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
protected void drawGridLine(Canvas c, float x, float y, Path gridLinePath) {
gridLinePath.moveTo(mViewPortHandler.contentRight(), y);
gridLinePath.lineTo(mViewPortHandler.contentLeft(), y);
// draw a path because lines don't support dashing on lower android versions
c.drawPath(gridLinePath, mGridPaint);
gridLinePath.reset();
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Draws the grid line at the specified position using the provided path.
*
* @param c
* @param x
* @param y
* @param gridLinePath
*/
protected void drawGridLine(Canvas c, float x, float y, Path gridLinePath) {
gridLinePath.moveTo(x, mViewPortHandler.contentBottom());
gridLinePath.lineTo(x, mViewPortHandler.contentTop());
// draw a path because lines don't support dashing on lower android versions
c.drawPath(gridLinePath, mGridPaint);
gridLinePath.reset();
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
path.reset();
for (int i = 0; i < paths.size(); i++) {
path.addPath(paths.get(i).getPath(), parentMatrix);
}
path.computeBounds(outBounds, false);
// Add padding to account for rounding errors.
outBounds.set(
outBounds.left - 1,
outBounds.top - 1,
outBounds.right + 1,
outBounds.bottom + 1
);
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
path.reset();
for (int i = 0; i < paths.size(); i++) {
this.path.addPath(paths.get(i).getPath(), parentMatrix);
}
path.computeBounds(outBounds, false);
// Add padding to account for rounding errors.
outBounds.set(
outBounds.left - 1,
outBounds.top - 1,
outBounds.right + 1,
outBounds.bottom + 1
);
}
代码示例来源:origin: airbnb/lottie-android
@Override public Path getPath() {
// TODO: cache this somehow.
matrix.reset();
if (transformAnimation != null) {
matrix.set(transformAnimation.getMatrix());
}
path.reset();
if (hidden) {
return path;
}
for (int i = contents.size() - 1; i >= 0; i--) {
Content content = contents.get(i);
if (content instanceof PathContent) {
path.addPath(((PathContent) content).getPath(), matrix);
}
}
return path;
}
代码示例来源:origin: PhilJay/MPAndroidChart
public void renderLimitLineLine(Canvas c, LimitLine limitLine, float[] position) {
mLimitLineSegmentsBuffer[0] = position[0];
mLimitLineSegmentsBuffer[1] = mViewPortHandler.contentTop();
mLimitLineSegmentsBuffer[2] = position[0];
mLimitLineSegmentsBuffer[3] = mViewPortHandler.contentBottom();
mLimitLinePath.reset();
mLimitLinePath.moveTo(mLimitLineSegmentsBuffer[0], mLimitLineSegmentsBuffer[1]);
mLimitLinePath.lineTo(mLimitLineSegmentsBuffer[2], mLimitLineSegmentsBuffer[3]);
mLimitLinePaint.setStyle(Paint.Style.STROKE);
mLimitLinePaint.setColor(limitLine.getLineColor());
mLimitLinePaint.setStrokeWidth(limitLine.getLineWidth());
mLimitLinePaint.setPathEffect(limitLine.getDashPathEffect());
c.drawPath(mLimitLinePath, mLimitLinePaint);
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
protected void drawZeroLine(Canvas c) {
int clipRestoreCount = c.save();
mZeroLineClippingRect.set(mViewPortHandler.getContentRect());
mZeroLineClippingRect.inset(-mYAxis.getZeroLineWidth(), 0.f);
c.clipRect(mLimitLineClippingRect);
// draw zero line
MPPointD pos = mTrans.getPixelForValues(0f, 0f);
mZeroLinePaint.setColor(mYAxis.getZeroLineColor());
mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth());
Path zeroLinePath = mDrawZeroLinePathBuffer;
zeroLinePath.reset();
zeroLinePath.moveTo((float) pos.x - 1, mViewPortHandler.contentTop());
zeroLinePath.lineTo((float) pos.x - 1, mViewPortHandler.contentBottom());
// draw a path because lines don't support dashing on lower android versions
c.drawPath(zeroLinePath, mZeroLinePaint);
c.restoreToCount(clipRestoreCount);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Draws the zero line.
*/
protected void drawZeroLine(Canvas c) {
int clipRestoreCount = c.save();
mZeroLineClippingRect.set(mViewPortHandler.getContentRect());
mZeroLineClippingRect.inset(0.f, -mYAxis.getZeroLineWidth());
c.clipRect(mZeroLineClippingRect);
// draw zero line
MPPointD pos = mTrans.getPixelForValues(0f, 0f);
mZeroLinePaint.setColor(mYAxis.getZeroLineColor());
mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth());
Path zeroLinePath = mDrawZeroLinePath;
zeroLinePath.reset();
zeroLinePath.moveTo(mViewPortHandler.contentLeft(), (float) pos.y);
zeroLinePath.lineTo(mViewPortHandler.contentRight(), (float) pos.y);
// draw a path because lines don't support dashing on lower android versions
c.drawPath(zeroLinePath, mZeroLinePaint);
c.restoreToCount(clipRestoreCount);
}
代码示例来源:origin: airbnb/lottie-android
@Override public void draw(Canvas canvas, Matrix parentMatrix, int parentAlpha) {
if (hidden) {
return;
}
L.beginSection("FillContent#draw");
paint.setColor(((ColorKeyframeAnimation) colorAnimation).getIntValue());
int alpha = (int) ((parentAlpha / 255f * opacityAnimation.getValue() / 100f) * 255);
paint.setAlpha(clamp(alpha, 0, 255));
if (colorFilterAnimation != null) {
paint.setColorFilter(colorFilterAnimation.getValue());
}
path.reset();
for (int i = 0; i < paths.size(); i++) {
path.addPath(paths.get(i).getPath(), parentMatrix);
}
canvas.drawPath(path, paint);
L.endSection("FillContent#draw");
}
代码示例来源:origin: airbnb/lottie-android
@Override public Path getPath() {
Path contentPath = contentGroup.getPath();
path.reset();
float copies = this.copies.getValue();
float offset = this.offset.getValue();
for (int i = (int) copies - 1; i >= 0; i--) {
matrix.set(transform.getMatrixForRepeater(i + offset));
path.addPath(contentPath, matrix);
}
return path;
}
代码示例来源:origin: airbnb/lottie-android
@Override public Path getPath() {
if (isPathValid) {
return path;
}
path.reset();
if (hidden) {
isPathValid = true;
return path;
}
path.set(shapeAnimation.getValue());
path.setFillType(Path.FillType.EVEN_ODD);
Utils.applyTrimPathIfNeeded(path, trimPath);
isPathValid = true;
return path;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testReset() throws Exception {
Path path = new Path();
path.moveTo(0, 3);
path.lineTo(2, 3);
path.quadTo(2, 3, 4, 5);
path.reset();
ShadowPath shadowPath = shadowOf(path);
List<ShadowPath.Point> points = shadowPath.getPoints();
assertEquals(0, points.size());
}
内容来源于网络,如有侵权,请联系作者删除!