本文整理汇总了Java中android.graphics.Path.rLineTo方法的典型用法代码示例。如果您正苦于以下问题:Java Path.rLineTo方法的具体用法?Java Path.rLineTo怎么用?Java Path.rLineTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.rLineTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawRoundRectPlain
import android.graphics.Path; //导入方法依赖的package包/类
public void drawRoundRectPlain(float left, float top, float right, float bottom, float rx, float ry, Paint paint, Canvas canvas) {
Path path = new Path();
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.rQuadTo(0, -ry, -rx, -ry);//top-right corner
path.rLineTo(-widthMinusCorners, 0);
path.rQuadTo(-rx, 0, -rx, ry); //top-left corner
path.rLineTo(0, heightMinusCorners);
path.rQuadTo(0, ry, rx, ry);//bottom-left corner
path.rLineTo(widthMinusCorners, 0);
path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner
path.rLineTo(0, -heightMinusCorners);
path.close();//Given close, last lineto can be removed.
canvas.drawPath(path, paint);
}
示例2: drawPath2
import android.graphics.Path; //导入方法依赖的package包/类
/**
* 画线 一天线
*
* @param canvas
*/
private void drawPath2(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
Path path = new Path();
path.lineTo(100, 100);
path.rLineTo(100, 0); //r 是相对路径 意思是从上次的(100,100)为起点,相对来说画一条向右 100 的直线
path.quadTo(100, 100, 500, 500);
canvas.drawPath(path, paint);
}
示例3: 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;
}
示例4: createRoundedRectPathPreApi21
import android.graphics.Path; //导入方法依赖的package包/类
private Path createRoundedRectPathPreApi21(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.rQuadTo(0, -ry, -rx, -ry);
path.rLineTo(-widthMinusCorners, 0);
path.rQuadTo(-rx, 0, -rx, ry);
path.rLineTo(0, heightMinusCorners);
if (conformToOriginalPost) {
path.rLineTo(0, ry);
path.rLineTo(width, 0);
path.rLineTo(0, -ry);
} else {
path.rQuadTo(0, ry, rx, ry);
path.rLineTo(widthMinusCorners, 0);
path.rQuadTo(rx, 0, rx, -ry);
}
path.rLineTo(0, -heightMinusCorners);
path.close();
return path;
}
示例5: 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;
}
示例6: createRoundedRectPathPreApi21
import android.graphics.Path; //导入方法依赖的package包/类
private Path createRoundedRectPathPreApi21(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.rQuadTo(0, -ry, -rx, -ry);
path.rLineTo(-widthMinusCorners, 0);
path.rQuadTo(-rx, 0, -rx, ry);
path.rLineTo(0, heightMinusCorners);
if (conformToOriginalPost) {
path.rLineTo(0, ry);
path.rLineTo(width, 0);
path.rLineTo(0, -ry);
} else {
path.rQuadTo(0, ry, rx, ry);
path.rLineTo(widthMinusCorners, 0);
path.rQuadTo(rx, 0, rx, -ry);
}
path.rLineTo(0, -heightMinusCorners);
path.close();
return path;
}
示例7: arcToBezier
import android.graphics.Path; //导入方法依赖的package包/类
/**
* Converts an arc to cubic Bezier segments and records them in p.
*
* @param p The target for the cubic Bezier segments
* @param cx The x coordinate center of the ellipse
* @param cy The y coordinate center of the ellipse
* @param a The radius of the ellipse in the horizontal direction
* @param b The radius of the ellipse in the vertical direction
* @param e1x E(eta1) x coordinate of the starting point of the arc
* @param e1y E(eta2) y coordinate of the starting point of the arc
* @param theta The angle that the ellipse bounding rectangle makes with horizontal plane
* @param start The start angle of the arc on the ellipse
* @param sweep The angle (positive or negative) of the sweep of the arc on the ellipse
*/
private static void arcToBezier(Path p,
double cx,
double cy,
double a,
double b,
double e1x,
double e1y,
double theta,
double start,
double sweep) {
// Taken from equations at: http://spaceroots.org/documents/ellipse/node8.html
// and http://www.spaceroots.org/documents/ellipse/node22.html
// Maximum of 45 degrees per cubic Bezier segment
int numSegments = (int) Math.ceil(Math.abs(sweep * 4 / Math.PI));
double eta1 = start;
double cosTheta = Math.cos(theta);
double sinTheta = Math.sin(theta);
double cosEta1 = Math.cos(eta1);
double sinEta1 = Math.sin(eta1);
double ep1x = (-a * cosTheta * sinEta1) - (b * sinTheta * cosEta1);
double ep1y = (-a * sinTheta * sinEta1) + (b * cosTheta * cosEta1);
double anglePerSegment = sweep / numSegments;
for (int i = 0; i < numSegments; i++) {
double eta2 = eta1 + anglePerSegment;
double sinEta2 = Math.sin(eta2);
double cosEta2 = Math.cos(eta2);
double e2x = cx + (a * cosTheta * cosEta2) - (b * sinTheta * sinEta2);
double e2y = cy + (a * sinTheta * cosEta2) + (b * cosTheta * sinEta2);
double ep2x = -a * cosTheta * sinEta2 - b * sinTheta * cosEta2;
double ep2y = -a * sinTheta * sinEta2 + b * cosTheta * cosEta2;
double tanDiff2 = Math.tan((eta2 - eta1) / 2);
double alpha =
Math.sin(eta2 - eta1) * (Math.sqrt(4 + (3 * tanDiff2 * tanDiff2)) - 1) / 3;
double q1x = e1x + alpha * ep1x;
double q1y = e1y + alpha * ep1y;
double q2x = e2x - alpha * ep2x;
double q2y = e2y - alpha * ep2y;
// Adding this no-op call to workaround a proguard related issue.
p.rLineTo(0, 0);
p.cubicTo((float) q1x,
(float) q1y,
(float) q2x,
(float) q2y,
(float) e2x,
(float) e2y);
eta1 = eta2;
e1x = e2x;
e1y = e2y;
ep1x = ep2x;
ep1y = ep2y;
}
}
示例8: rLineToTest
import android.graphics.Path; //导入方法依赖的package包/类
private void rLineToTest(Canvas canvas) {
Path path = new Path();
path.moveTo(100, 100);
path.rLineTo(0, 200);
canvas.drawPath(path, paint);
}
示例9: init
import android.graphics.Path; //导入方法依赖的package包/类
public void init() {
float temp = height / 7f;
monthHeight = 0;//(float) ((temp + temp * 0.3f) * 0.6);
//monthChangeWidth = monthHeight * 1.5f;
weekHeight = (float) ((temp + temp * 0.3f) * 0.7);
cellHeight = (height - monthHeight - weekHeight) / 6f;
cellWidth = width / 7f;
borderPaint = new Paint();
borderPaint.setColor(borderColor);
borderPaint.setStyle(Paint.Style.STROKE);
borderWidth = (float) (0.5 * density);
// Log.d(TAG, "borderwidth:" + borderWidth);
borderWidth = borderWidth < 1 ? 1 : borderWidth;
borderPaint.setStrokeWidth(borderWidth);
monthPaint = new Paint();
monthPaint.setColor(textColor);
monthPaint.setAntiAlias(true);
float textSize = cellHeight * 0.4f;
Log.d(TAG, "text size:" + textSize);
monthPaint.setTextSize(textSize);
monthPaint.setTypeface(Typeface.DEFAULT_BOLD);
weekPaint = new Paint();
weekPaint.setColor(textColor);
weekPaint.setAntiAlias(true);
float weekTextSize = weekHeight * 0.6f;
weekPaint.setTextSize(weekTextSize);
weekPaint.setTypeface(Typeface.DEFAULT_BOLD);
datePaint = new Paint();
datePaint.setColor(textColor);
datePaint.setAntiAlias(true);
float cellTextSize = cellHeight * 0.5f;
datePaint.setTextSize(cellTextSize);
datePaint.setTypeface(Typeface.DEFAULT);
boxPath = new Path();
//boxPath.addRect(0, 0, width, height, Direction.CW);
//boxPath.moveTo(0, monthHeight);
boxPath.rLineTo(width, 0);
boxPath.moveTo(0, monthHeight + weekHeight);
boxPath.rLineTo(width, 0);
for (int i = 1; i < 6; i++) {
boxPath.moveTo(0, monthHeight + weekHeight + i * cellHeight);
boxPath.rLineTo(width, 0);
boxPath.moveTo(i * cellWidth, monthHeight);
boxPath.rLineTo(0, height - monthHeight);
}
boxPath.moveTo(6 * cellWidth, monthHeight);
boxPath.rLineTo(0, height - monthHeight);
//preMonthBtnPath = new Path();
//int btnHeight = (int) (monthHeight * 0.6f);
//preMonthBtnPath.moveTo(monthChangeWidth / 2f, monthHeight / 2f);
//preMonthBtnPath.rLineTo(btnHeight / 2f, -btnHeight / 2f);
//preMonthBtnPath.rLineTo(0, btnHeight);
//preMonthBtnPath.close();
//nextMonthBtnPath = new Path();
//nextMonthBtnPath.moveTo(width - monthChangeWidth / 2f,
// monthHeight / 2f);
//nextMonthBtnPath.rLineTo(-btnHeight / 2f, -btnHeight / 2f);
//nextMonthBtnPath.rLineTo(0, btnHeight);
//nextMonthBtnPath.close();
monthChangeBtnPaint = new Paint();
monthChangeBtnPaint.setAntiAlias(true);
monthChangeBtnPaint.setStyle(Paint.Style.FILL_AND_STROKE);
monthChangeBtnPaint.setColor(btnColor);
cellBgPaint = new Paint();
cellBgPaint.setAntiAlias(true);
cellBgPaint.setStyle(Paint.Style.FILL);
cellBgPaint.setColor(cellSelectedColor);
}
示例10: drawPath
import android.graphics.Path; //导入方法依赖的package包/类
private void drawPath(VGroup vGroup, VPath vPath, Canvas canvas, int w, int h, ColorFilter filter) {
float scaleX = ((float) w) / this.mViewportWidth;
float scaleY = ((float) h) / this.mViewportHeight;
float minScale = Math.min(scaleX, scaleY);
Matrix groupStackedMatrix = vGroup.mStackedMatrix;
this.mFinalPathMatrix.set(groupStackedMatrix);
this.mFinalPathMatrix.postScale(scaleX, scaleY);
float matrixScale = getMatrixScale(groupStackedMatrix);
if (matrixScale != 0.0f) {
vPath.toPath(this.mPath);
Path path = this.mPath;
this.mRenderPath.reset();
if (vPath.isClipPath()) {
this.mRenderPath.addPath(path, this.mFinalPathMatrix);
canvas.clipPath(this.mRenderPath, Op.REPLACE);
return;
}
VFullPath fullPath = (VFullPath) vPath;
if (!(fullPath.mTrimPathStart == 0.0f && fullPath.mTrimPathEnd == 1.0f)) {
float start = (fullPath.mTrimPathStart + fullPath.mTrimPathOffset) % 1.0f;
float end = (fullPath.mTrimPathEnd + fullPath.mTrimPathOffset) % 1.0f;
if (this.mPathMeasure == null) {
this.mPathMeasure = new PathMeasure();
}
this.mPathMeasure.setPath(this.mPath, false);
float len = this.mPathMeasure.getLength();
start *= len;
end *= len;
path.reset();
if (start > end) {
this.mPathMeasure.getSegment(start, len, path, true);
this.mPathMeasure.getSegment(0.0f, end, path, true);
} else {
this.mPathMeasure.getSegment(start, end, path, true);
}
path.rLineTo(0.0f, 0.0f);
}
this.mRenderPath.addPath(path, this.mFinalPathMatrix);
if (fullPath.mFillColor != 0) {
if (this.mFillPaint == null) {
this.mFillPaint = new Paint();
this.mFillPaint.setStyle(Style.FILL);
this.mFillPaint.setAntiAlias(true);
}
Paint fillPaint = this.mFillPaint;
fillPaint.setColor(VectorDrawableCompat.applyAlpha(fullPath.mFillColor, fullPath.mFillAlpha));
fillPaint.setColorFilter(filter);
canvas.drawPath(this.mRenderPath, fillPaint);
}
if (fullPath.mStrokeColor != 0) {
if (this.mStrokePaint == null) {
this.mStrokePaint = new Paint();
this.mStrokePaint.setStyle(Style.STROKE);
this.mStrokePaint.setAntiAlias(true);
}
Paint strokePaint = this.mStrokePaint;
if (fullPath.mStrokeLineJoin != null) {
strokePaint.setStrokeJoin(fullPath.mStrokeLineJoin);
}
if (fullPath.mStrokeLineCap != null) {
strokePaint.setStrokeCap(fullPath.mStrokeLineCap);
}
strokePaint.setStrokeMiter(fullPath.mStrokeMiterlimit);
strokePaint.setColor(VectorDrawableCompat.applyAlpha(fullPath.mStrokeColor, fullPath.mStrokeAlpha));
strokePaint.setColorFilter(filter);
strokePaint.setStrokeWidth(fullPath.mStrokeWidth * (minScale * matrixScale));
canvas.drawPath(this.mRenderPath, strokePaint);
}
}
}
示例11: renderOnCanvas
import android.graphics.Path; //导入方法依赖的package包/类
private void renderOnCanvas(Canvas canvas, float scale) {
canvas.save();
canvas.scale(scale, scale);
mTempPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
// Draw the pattern by creating the paths, adjusting the colors and drawing them. The path
// values are extracted from the SVG of the pattern file.
if (sPatternPaths == null) {
sPatternPaths = new Path[NUM_PATHS];
// Lightness values of the pattern, range 0 - 255
sPatternLightness = new int[] { 10, 40, 51, 66, 91, 112, 130 };
Path p = sPatternPaths[0] = new Path();
p.moveTo(1029.4f, 357.5f);
p.lineTo(1366f, 759.1f);
p.lineTo(1366f, 0f);
p.lineTo(1137.7f, 0f);
p.close();
p = sPatternPaths[1] = new Path();
p.moveTo(1138.1f, 0f);
p.rLineTo(-144.8f, 768f);
p.rLineTo(372.7f, 0f);
p.rLineTo(0f, -524f);
p.cubicTo(1290.7f, 121.6f, 1219.2f, 41.1f, 1178.7f, 0f);
p.close();
p = sPatternPaths[2] = new Path();
p.moveTo(949.8f, 768f);
p.rCubicTo(92.6f, -170.6f, 213f, -440.3f, 269.4f, -768f);
p.lineTo(585f, 0f);
p.rLineTo(2.1f, 766f);
p.close();
p = sPatternPaths[3] = new Path();
p.moveTo(471.1f, 768f);
p.rMoveTo(704.5f, 0f);
p.cubicTo(1123.6f, 563.3f, 1027.4f, 275.2f, 856.2f, 0f);
p.lineTo(476.4f, 0f);
p.rLineTo(-5.3f, 768f);
p.close();
p = sPatternPaths[4] = new Path();
p.moveTo(323.1f, 768f);
p.moveTo(777.5f, 768f);
p.cubicTo(661.9f, 348.8f, 427.2f, 21.4f, 401.2f, 25.4f);
p.lineTo(323.1f, 768f);
p.close();
p = sPatternPaths[5] = new Path();
p.moveTo(178.44286f, 766.85714f);
p.lineTo(308.7f, 768f);
p.cubicTo(381.7f, 604.6f, 481.6f, 344.3f, 562.2f, 0f);
p.lineTo(0f, 0f);
p.close();
p = sPatternPaths[6] = new Path();
p.moveTo(146f, 0f);
p.lineTo(0f, 0f);
p.lineTo(0f, 768f);
p.lineTo(394.2f, 768f);
p.cubicTo(327.7f, 475.3f, 228.5f, 201f, 146f, 0f);
p.close();
}
for (int i = 0; i < NUM_PATHS; i++) {
// Color is 0xAARRGGBB, so alpha << 24 will create a color with (alpha)% black.
// Although the color components don't really matter, since the backing bitmap cache is
// ALPHA_8.
mTempPaint.setColor(sPatternLightness[i] << 24);
canvas.drawPath(sPatternPaths[i], mTempPaint);
}
canvas.restore();
mTempPaint.reset();
}