本文整理了Java中android.graphics.Path.close()
方法的一些代码示例,展示了Path.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.close()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:close
暂无
代码示例来源: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 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
@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: TeamNewPipe/NewPipe
private void setupMarquee(int width, int height) {
mMarqueeSize = (int) ((width * 10f) / 100f);// the size is 10% of the width
mMarqueeLine.rewind();
mMarqueeLine.moveTo(-mMarqueeSize, -mMarqueeSize);
mMarqueeLine.lineTo(-mMarqueeSize * 4, height + mMarqueeSize);
mMarqueeLine.close();
}
}
代码示例来源:origin: seven332/EhViewer
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mPath.reset();
mPath.moveTo(bounds.left, bounds.top);
mPath.lineTo(bounds.right, bounds.top);
mPath.lineTo(bounds.right, bounds.bottom);
mPath.close();
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void draw(@NonNull Canvas canvas) {
final Drawable drawable = ArrowDrawable.this;
final Rect bounds = drawable.getBounds();
int width = bounds.width();
int height = bounds.height();
if (mWidth != width || mHeight != height) {
int lineWidth = width * 30 / 225;
mPath.reset();
float vector1 = (float) (lineWidth * Math.sin(Math.PI/4));
float vector2 = (float) (lineWidth / Math.sin(Math.PI/4));
mPath.moveTo(width / 2, height);
mPath.lineTo(0, height / 2);
mPath.lineTo(vector1, height / 2 - vector1);
mPath.lineTo(width / 2 - lineWidth / 2, height - vector2 - lineWidth / 2);
mPath.lineTo(width / 2 - lineWidth / 2, 0);
mPath.lineTo(width / 2 + lineWidth / 2, 0);
mPath.lineTo(width / 2 + lineWidth / 2, height - vector2 - lineWidth / 2);
mPath.lineTo(width - vector1, height / 2 - vector1);
mPath.lineTo(width, height / 2);
mPath.close();
mWidth = width;
mHeight = height;
}
canvas.drawPath(mPath, mPaint);
}
}
代码示例来源:origin: facebook/litho
private void buildClippingCorners() {
mCornerPath.reset();
RectF oval = new RectF(0, 0, mCornerRadius * 2, mCornerRadius * 2);
mCornerPath.setFillType(Path.FillType.EVEN_ODD);
mCornerPath.moveTo(0, 0);
mCornerPath.lineTo(0, mCornerRadius);
mCornerPath.arcTo(oval, 180f, 90f, true);
mCornerPath.lineTo(0, 0);
mCornerPath.close();
}
}
代码示例来源:origin: hackware1993/MagicIndicator
/**
* 绘制贝塞尔曲线
*
* @param canvas
*/
private void drawBezierCurve(Canvas canvas) {
mPath.reset();
float y = getHeight() - mYOffset - mMaxCircleRadius;
mPath.moveTo(mRightCircleX, y);
mPath.lineTo(mRightCircleX, y - mRightCircleRadius);
mPath.quadTo(mRightCircleX + (mLeftCircleX - mRightCircleX) / 2.0f, y, mLeftCircleX, y - mLeftCircleRadius);
mPath.lineTo(mLeftCircleX, y + mLeftCircleRadius);
mPath.quadTo(mRightCircleX + (mLeftCircleX - mRightCircleX) / 2.0f, y, mRightCircleX, y + mRightCircleRadius);
mPath.close(); // 闭合
canvas.drawPath(mPath, mPaint);
}
代码示例来源:origin: rey5137/material
@Override
protected void onBoundsChange(Rect bounds) {
float x = bounds.exactCenterX();
float y = bounds.exactCenterY();
mPath.reset();
mPath.moveTo(x, y + mSize / 2f);
mPath.lineTo(x - mSize, y - mSize / 2f);
mPath.lineTo(x + mSize, y - mSize / 2f);
mPath.close();
}
代码示例来源:origin: CarGuo/GSYVideoPlayer
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w * 9 / 10;
mHeight = h * 9 / 10;
mCircleRadius = mWidth / dp2px(4);
mCenterX = w / 2;
mCenterY = h / 2;
mRectF = new RectF(mCenterX - mCircleRadius, mCenterY + 0.6f * mCircleRadius,
mCenterX + mCircleRadius, mCenterY + 2.6f * mCircleRadius);
mBgRectF = new RectF(mCenterX - mWidth / 2 ,mCenterY - mHeight / 2 ,mCenterX + mWidth / 2, mCenterY + mHeight / 2);
mPath.moveTo(mCenterX - mCircleRadius, mCenterY + 1.8f * mCircleRadius);
mPath.lineTo(mCenterX - mCircleRadius, mCenterY - 1.8f * mCircleRadius);
mPath.lineTo(mCenterX + mCircleRadius, mCenterY);
mPath.close();
mPathMeasure.setPath(mPath, false);
mPathLength = mPathMeasure.getLength();
}
代码示例来源:origin: scwang90/SmartRefreshLayout
private void makeBezierPath() {
mPath.reset();
mPath.addCircle(topCircle.x, topCircle.y, topCircle.radius, Path.Direction.CCW);
if (bottomCircle.y > topCircle.y + DensityUtil.dp2px(1)) {
mPath.addCircle(bottomCircle.x, bottomCircle.y, bottomCircle.radius, Path.Direction.CCW);
//获取两圆的两个切线形成的四个切点
double angle = getAngle();
float top_x1 = (float) (topCircle.x - topCircle.radius * Math.cos(angle));
float top_y1 = (float) (topCircle.y + topCircle.radius * Math.sin(angle));
float top_x2 = (float) (topCircle.x + topCircle.radius * Math.cos(angle));
float top_y2 = top_y1;
float bottom_x1 = (float) (bottomCircle.x - bottomCircle.radius * Math.cos(angle));
float bottom_y1 = (float) (bottomCircle.y + bottomCircle.radius * Math.sin(angle));
float bottom_x2 = (float) (bottomCircle.x + bottomCircle.radius * Math.cos(angle));
float bottom_y2 = bottom_y1;
mPath.moveTo(topCircle.x, topCircle.y);
mPath.lineTo(top_x1, top_y1);
mPath.quadTo((bottomCircle.x - bottomCircle.radius),
(bottomCircle.y + topCircle.y) / 2,
bottom_x1,bottom_y1);
mPath.lineTo(bottom_x2, bottom_y2);
mPath.quadTo((bottomCircle.x + bottomCircle.radius),
(bottomCircle.y + top_y2) / 2,
top_x2,top_y2);
}
mPath.close();
}
代码示例来源:origin: mikepenz/Android-Iconics
@Override
protected void onBoundsChange(@NonNull Rect bounds) {
offsetIcon(bounds);
try {
mPath.close();
} catch (Exception ignored) {
}
super.onBoundsChange(bounds);
}
代码示例来源:origin: airbnb/lottie-android
@Override public Path getPath() {
if (isPathValid) {
return path;
}
path.reset();
if (hidden) {
isPathValid = true;
return path;
}
switch (type) {
case Star:
createStarPath();
break;
case Polygon:
createPolygonPath();
break;
}
path.close();
Utils.applyTrimPathIfNeeded(path, trimPath);
isPathValid = true;
return path;
}
代码示例来源:origin: fython/MaterialStepperView
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (isPreLollipop()) {
float halfWidth = w / 2f;
float halfHeight = h / 2f;
path.reset();
path.addCircle(halfWidth, halfHeight, Math.min(halfWidth, halfHeight), Path.Direction.CW);
path.close();
}
}
代码示例来源:origin: airbnb/lottie-android
path.lineTo(points[6], points[7]);
path.lineTo(points[0], points[1]);
path.close();
canvas.drawPath(path, paint);
代码示例来源:origin: airbnb/lottie-android
public static void getPathFromData(ShapeData shapeData, Path outPath) {
outPath.reset();
PointF initialPoint = shapeData.getInitialPoint();
outPath.moveTo(initialPoint.x, initialPoint.y);
pathFromDataCurrentPoint.set(initialPoint.x, initialPoint.y);
for (int i = 0; i < shapeData.getCurves().size(); i++) {
CubicCurveData curveData = shapeData.getCurves().get(i);
PointF cp1 = curveData.getControlPoint1();
PointF cp2 = curveData.getControlPoint2();
PointF vertex = curveData.getVertex();
if (cp1.equals(pathFromDataCurrentPoint) && cp2.equals(vertex)) {
// On some phones like Samsung phones, zero valued control points can cause artifacting.
// https://github.com/airbnb/lottie-android/issues/275
//
// This does its best to add a tiny value to the vertex without affecting the final
// animation as much as possible.
// outPath.rMoveTo(0.01f, 0.01f);
outPath.lineTo(vertex.x, vertex.y);
} else {
outPath.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, vertex.x, vertex.y);
}
pathFromDataCurrentPoint.set(vertex.x, vertex.y);
}
if (shapeData.isClosed()) {
outPath.close();
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
filled.close();
代码示例来源:origin: PhilJay/MPAndroidChart
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {
float fillMin = dataSet.getFillFormatter()
.getFillLinePosition(dataSet, mChart);
spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
spline.close();
trans.pathValueToPixel(spline);
final Drawable drawable = dataSet.getFillDrawable();
if (drawable != null) {
drawFilledPath(c, spline, drawable);
} else {
drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void close() {
Path path = new Path();
assertThat(path.isEmpty()).isTrue();
path.close();
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
limitPath.lineTo(pOut.x, pOut.y);
limitPath.close();
内容来源于网络,如有侵权,请联系作者删除!