本文整理汇总了Java中android.graphics.Path.arcTo方法的典型用法代码示例。如果您正苦于以下问题:Java Path.arcTo方法的具体用法?Java Path.arcTo怎么用?Java Path.arcTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.arcTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpTopPath
import android.graphics.Path; //导入方法依赖的package包/类
private void setUpTopPath(RectF rect, Path path) {
path.moveTo(rect.left + Math.min(mArrowPosition, mAngle), rect.top + mArrowHeight);
path.lineTo(rect.left + mArrowPosition, rect.top + mArrowHeight);
path.lineTo(rect.left + mArrowWidth / 2 + mArrowPosition, rect.top);
path.lineTo(rect.left + mArrowWidth + mArrowPosition, rect.top + mArrowHeight);
path.lineTo(rect.right - mAngle, rect.top + mArrowHeight);
path.arcTo(new RectF(rect.right - mAngle, rect.top + mArrowHeight, rect.right, mAngle + rect.top + mArrowHeight), 270, 90);
path.lineTo(rect.right, rect.bottom - mAngle);
path.arcTo(new RectF(rect.right - mAngle, rect.bottom - mAngle, rect.right, rect.bottom), 0, 90);
path.lineTo(rect.left + mAngle, rect.bottom);
path.arcTo(new RectF(rect.left, rect.bottom - mAngle, mAngle + rect.left, rect.bottom), 90, 90);
path.lineTo(rect.left, rect.top + mArrowHeight + mAngle);
path.arcTo(new RectF(rect.left, rect.top + mArrowHeight, mAngle + rect.left, mAngle + rect.top + mArrowHeight), 180, 90);
path.close();
}
示例2: drawPath5
import android.graphics.Path; //导入方法依赖的package包/类
/**
* @param canvas arcTo addArc
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void drawPath5(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
/**
* 这个方法和 Canvas.drawArc() 比起来,少了一个参数 useCenter,而多了一个参数 forceMoveTo 。
少了 useCenter ,
是因为 arcTo() 只用来画弧形而不画扇形,所以不再需要 useCenter 参数;
而多出来的这个 forceMoveTo 参数的意思是,
绘制是要「抬一下笔移动过去」,
还是「直接拖着笔过去」,区别在于是否留下移动的痕迹。
其实 addArc 意思是 arcTo(xx, xx, xx, xx, xx, xx, true); 的简化版 将forceMoveTo 写死为 true 就是 跳过去然后画
*/
Path path = new Path();
path.lineTo(100, 100);
path.arcTo(100, 100, 300, 300, -90, 90, true); // 强制移动到弧形起点(无痕迹)
canvas.drawPath(path, paint);
}
示例3: leftPath
import android.graphics.Path; //导入方法依赖的package包/类
public void leftPath(RectF rect, Path path) {
path.moveTo(mAngle + mArrowWidth, rect.top);
path.lineTo(rect.width(), rect.top);
path.arcTo(new RectF(rect.right - mAngle * 2, rect.top, rect.right,
mAngle * 2 + rect.top), 270, 90);
path.lineTo(rect.right, rect.top);
path.arcTo(new RectF(rect.right - mAngle * 2, rect.bottom - mAngle * 2,
rect.right, rect.bottom), 0, 90);
path.lineTo(rect.left + mArrowWidth, rect.bottom);
path.arcTo(new RectF(rect.left + mArrowWidth, rect.bottom - mAngle * 2,
mAngle * 2 + rect.left + mArrowWidth, rect.bottom), 90, 90);
path.lineTo(rect.left + mArrowWidth, mArrowTop + mArrowHeight);
path.lineTo(rect.left, mArrowTop - mArrowOffset);
path.lineTo(rect.left + mArrowWidth, mArrowTop);
path.lineTo(rect.left + mArrowWidth, rect.top);
path.arcTo(new RectF(rect.left + mArrowWidth, rect.top, mAngle * 2
+ rect.left + mArrowWidth, mAngle * 2 + rect.top), 180, 90);
path.close();
}
示例4: initTopRoundedPath
import android.graphics.Path; //导入方法依赖的package包/类
private void initTopRoundedPath(RectF rect, Path path, float strokeWidth) {
path.moveTo(rect.left + Math.min(mArrowPosition, mCornersRadius) + strokeWidth, rect.top + mArrowHeight + strokeWidth);
path.lineTo(rect.left + mArrowPosition + (strokeWidth / 2), rect.top + mArrowHeight + strokeWidth);
path.lineTo(rect.left + mArrowWidth / 2 + mArrowPosition, rect.top + strokeWidth + strokeWidth);
path.lineTo(rect.left + mArrowWidth + mArrowPosition - (strokeWidth / 2), rect.top + mArrowHeight + strokeWidth);
path.lineTo(rect.right - mCornersRadius - strokeWidth, rect.top + mArrowHeight + strokeWidth);
path.arcTo(new RectF(rect.right - mCornersRadius,
rect.top + mArrowHeight + strokeWidth, rect.right - strokeWidth, mCornersRadius + rect.top + mArrowHeight), 270, 90);
path.lineTo(rect.right - strokeWidth, rect.bottom - mCornersRadius - strokeWidth);
path.arcTo(new RectF(rect.right - mCornersRadius, rect.bottom - mCornersRadius,
rect.right - strokeWidth, rect.bottom - strokeWidth), 0, 90);
path.lineTo(rect.left + mCornersRadius + strokeWidth, rect.bottom - strokeWidth);
path.arcTo(new RectF(rect.left + strokeWidth, rect.bottom - mCornersRadius,
mCornersRadius + rect.left, rect.bottom - strokeWidth), 90, 90);
path.lineTo(rect.left + strokeWidth, rect.top + mArrowHeight + mCornersRadius + strokeWidth);
path.arcTo(new RectF(rect.left + strokeWidth, rect.top + mArrowHeight + strokeWidth, mCornersRadius
+ rect.left, mCornersRadius + rect.top + mArrowHeight), 180, 90);
path.close();
}
示例5: initRightRoundedPath
import android.graphics.Path; //导入方法依赖的package包/类
private void initRightRoundedPath(RectF rect, Path path, float strokeWidth) {
path.moveTo(rect.left + mCornersRadius + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - mCornersRadius - mArrowWidth - strokeWidth, rect.top + strokeWidth);
path.arcTo(new RectF(rect.right - mCornersRadius - mArrowWidth,
rect.top + strokeWidth, rect.right - mArrowWidth - strokeWidth, mCornersRadius + rect.top), 270, 90);
path.lineTo(rect.right - mArrowWidth - strokeWidth, mArrowPosition + (strokeWidth / 2));
path.lineTo(rect.right - strokeWidth - strokeWidth, mArrowPosition + mArrowHeight / 2);
path.lineTo(rect.right - mArrowWidth - strokeWidth, mArrowPosition + mArrowHeight - (strokeWidth / 2));
path.lineTo(rect.right - mArrowWidth - strokeWidth, rect.bottom - mCornersRadius - strokeWidth);
path.arcTo(new RectF(rect.right - mCornersRadius - mArrowWidth, rect.bottom - mCornersRadius,
rect.right - mArrowWidth - strokeWidth, rect.bottom - strokeWidth), 0, 90);
path.lineTo(rect.left + mArrowWidth + strokeWidth, rect.bottom - strokeWidth);
path.arcTo(new RectF(rect.left + strokeWidth, rect.bottom - mCornersRadius,
mCornersRadius + rect.left, rect.bottom - strokeWidth), 90, 90);
path.arcTo(new RectF(rect.left + strokeWidth, rect.top + strokeWidth, mCornersRadius
+ rect.left, mCornersRadius + rect.top), 180, 90);
path.close();
}
示例6: initPaint
import android.graphics.Path; //导入方法依赖的package包/类
private void initPaint() {
paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(background);
paint.setStyle(Style.FILL);
int width = getMeasuredWidth();
int height = getMeasuredHeight();
path = new Path();
path.moveTo(0, height);
path.lineTo(0, 0);
path.lineTo(width, 0);
path.lineTo(width, height);
path.lineTo(0, height);
path.arcTo(new RectF(Margin, Margin, width - Margin, width - Margin), 180, -359, true);
path.close();
}
示例7: rightPath
import android.graphics.Path; //导入方法依赖的package包/类
public void rightPath(RectF rect, Path path) {
path.moveTo(mAngle, rect.top);
path.lineTo(rect.width(), rect.top);
path.arcTo(new RectF(rect.right - mAngle * 2 - mArrowWidth, rect.top,
rect.right - mArrowWidth, mAngle * 2 + rect.top), 270, 90);
path.lineTo(rect.right - mArrowWidth, mArrowTop);
path.lineTo(rect.right, mArrowTop - mArrowOffset);
path.lineTo(rect.right - mArrowWidth, mArrowTop + mArrowHeight);
path.lineTo(rect.right - mArrowWidth, rect.height() - mAngle);
path.arcTo(new RectF(rect.right - mAngle * 2 - mArrowWidth, rect.bottom
- mAngle * 2, rect.right - mArrowWidth, rect.bottom), 0, 90);
path.lineTo(rect.left, rect.bottom);
path.arcTo(new RectF(rect.left, rect.bottom - mAngle * 2, mAngle * 2
+ rect.left, rect.bottom), 90, 90);
path.lineTo(rect.left, rect.top);
path.arcTo(new RectF(rect.left, rect.top, mAngle * 2 + rect.left,
mAngle * 2 + rect.top), 180, 90);
path.close();
}
示例8: drawLiftUp
import android.graphics.Path; //导入方法依赖的package包/类
private void drawLiftUp(Canvas canvas) {
Path path = new Path();
path.moveTo(0, roundHeight);
path.lineTo(0, 0);
path.lineTo(roundWidth, 0);
path.arcTo(new RectF(0, 0, roundWidth * 2, roundHeight * 2), -90, -90);
path.close();
canvas.drawPath(path, paint);
}
示例9: createRoundedRectPathApi21
import android.graphics.Path; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Path createRoundedRectPathApi21(Path path, float left, float top, float right, float bottom, float rx, float ry, boolean
conformToOriginalPost) {
if (rx < 0) rx = 0;
if (ry < 0) ry = 0;
float width = right - left;
float height = bottom - top;
if (rx > width / 2) rx = width / 2;
if (ry > height / 2) ry = height / 2;
float widthMinusCorners = (width - (2 * rx));
float heightMinusCorners = (height - (2 * ry));
path.moveTo(right, top + ry);
path.arcTo(right - 2 * rx, top, right, top + 2 * ry, 0, -90, false);
path.rLineTo(-widthMinusCorners, 0);
path.arcTo(left, top, left + 2 * rx, top + 2 * ry, 270, -90, false);
path.rLineTo(0, heightMinusCorners);
if (conformToOriginalPost) {
path.rLineTo(0, ry);
path.rLineTo(width, 0);
path.rLineTo(0, -ry);
} else {
path.arcTo(left, bottom - 2 * ry, left + 2 * rx, bottom, 180, -90, false);
path.rLineTo(widthMinusCorners, 0);
path.arcTo(right - 2 * rx, bottom - 2 * ry, right, bottom, 90, -90, false);
}
path.rLineTo(0, -heightMinusCorners);
path.close();
return path;
}
示例10: createWaitPath
import android.graphics.Path; //导入方法依赖的package包/类
private Path createWaitPath(RectF bounds) {
Path path = new Path();
//create circle
path.moveTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY());
//create w
path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f,
bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.quadTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() + mWaitCircleRadius * 0.05f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f,
bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f,
bounds.centerX() + mWaitCircleRadius, bounds.centerY());
//create arc
path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 0, -359);
path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 1, -359);
path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 2, -2);
//create w
path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f,
bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.quadTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius,
bounds.centerX() + mWaitCircleRadius * 0.05f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f,
bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f,
bounds.centerX() + mWaitCircleRadius, bounds.centerY());
return path;
}
示例11: createRoundedRectPathApi21
import android.graphics.Path; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Path createRoundedRectPathApi21(Path path, float left, float top, float right,
float bottom, float rx, float ry, boolean
conformToOriginalPost) {
if (rx < 0) rx = 0;
if (ry < 0) ry = 0;
float width = right - left;
float height = bottom - top;
if (rx > width / 2) rx = width / 2;
if (ry > height / 2) ry = height / 2;
float widthMinusCorners = (width - (2 * rx));
float heightMinusCorners = (height - (2 * ry));
path.moveTo(right, top + ry);
path.arcTo(right - 2 * rx, top, right, top + 2 * ry, 0, -90, false);
path.rLineTo(-widthMinusCorners, 0);
path.arcTo(left, top, left + 2 * rx, top + 2 * ry, 270, -90, false);
path.rLineTo(0, heightMinusCorners);
if (conformToOriginalPost) {
path.rLineTo(0, ry);
path.rLineTo(width, 0);
path.rLineTo(0, -ry);
} else {
path.arcTo(left, bottom - 2 * ry, left + 2 * rx, bottom, 180, -90, false);
path.rLineTo(widthMinusCorners, 0);
path.arcTo(right - 2 * rx, bottom - 2 * ry, right, bottom, 90, -90, false);
}
path.rLineTo(0, -heightMinusCorners);
path.close();
return path;
}
示例12: drawRightDown
import android.graphics.Path; //导入方法依赖的package包/类
private void drawRightDown(Canvas canvas) {
Path path = new Path();
path.moveTo(getWidth() - roundWidth, getHeight());
path.lineTo(getWidth(), getHeight());
path.lineTo(getWidth(), getHeight() - roundHeight);
path.arcTo(new RectF(getWidth() - roundWidth * 2, getHeight() - roundHeight * 2, getWidth(), getHeight()), -0, 90);
path.close();
canvas.drawPath(path, paint);
}
示例13: demo
import android.graphics.Path; //导入方法依赖的package包/类
private void demo(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
Path path = new Path();
RectF rectFLeft = new RectF();
RectF rectfRight = new RectF();
// 矩形
float x1 = (getWidth() - getHeight() / 2) / 2;
float y1 = getHeight() / 4;
float x2 = getWidth() / 2;
float y2 = getHeight() / 2;
rectFLeft.set(x1, y1, x2, y2);
float xx1 = getWidth() / 2;
float yy1 = getHeight() / 4;
float xx2 = getWidth() - x1;
float yy2 = getHeight() / 2;
rectfRight.set(xx1, yy1, xx2, yy2);
path.arcTo(rectFLeft, -225, 225, false);
path.arcTo(rectfRight, -180, 225, false);
path.lineTo(getWidth() / 2, getHeight() - y1);
path.close();
canvas.drawPath(path, paint);
}
示例14: getOutline
import android.graphics.Path; //导入方法依赖的package包/类
private Path getOutline(float scale) {
RectF outerBB = new RectF(-mOuter * scale, -mOuter * scale, mOuter * scale, mOuter * scale);
RectF innerBB = new RectF(-mInner * scale, -mInner * scale, mInner * scale, mInner * scale);
double gamma = (mInner + mOuter) * Math.sin(Math.toRadians(mGap / 2.0f));
float alphaOuter = (float) Math.toDegrees(Math.asin( gamma / (mOuter * 2.0f)));
float alphaInner = (float) Math.toDegrees(Math.asin( gamma / (mInner * 2.0f)));
Path path = new Path();
path.arcTo(outerBB, mStart + alphaOuter, mSweep - 2 * alphaOuter, true);
path.arcTo(innerBB, mStart + mSweep - alphaInner, 2 * alphaInner - mSweep);
path.close();
return path;
}
示例15: drawLiftDown
import android.graphics.Path; //导入方法依赖的package包/类
private void drawLiftDown(Canvas canvas) {
Path path = new Path();
path.moveTo(0, getHeight() - roundHeight);
path.lineTo(0, getHeight());
path.lineTo(roundWidth, getHeight());
path.arcTo(new RectF(
0,
getHeight() - roundHeight * 2,
0 + roundWidth * 2,
getHeight()),
90,
90);
path.close();
canvas.drawPath(path, paint);
}