本文整理汇总了Java中android.graphics.Path.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Java Path.moveTo方法的具体用法?Java Path.moveTo怎么用?Java Path.moveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreloadProgressPath
import android.graphics.Path; //导入方法依赖的package包/类
private Path getPreloadProgressPath(Context context) {
if (AndroidVersion.isAtLeastOreo()) {
try {
// Try to load the path from Mask Icon
Drawable icon = context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper);
icon.setBounds(0, 0,
PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE);
return (Path) icon.getClass().getMethod("getIconMask").invoke(icon);
} catch (Exception e) {
e.printStackTrace();
}
}
// Create a circle static from top center and going clockwise.
Path p = new Path();
p.moveTo(PreloadIconDrawable.PATH_SIZE / 2, 0);
p.addArc(0, 0, PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE, -90, 360);
return p;
}
示例2: drawArea
import android.graphics.Path; //导入方法依赖的package包/类
private void drawArea(Canvas canvas) {
Path path = new Path();
//原理就是用path根据各方向值创建一个封闭的区域,然后填充
for (int i = 0; i < eageCount; i++) {
float rate = pointValue.get(i);
float currentX = maxPointXList.get(i) * rate;
float currentY = maxPointYList.get(i) * rate;
if (i == 0) {
path.moveTo(currentX, currentY);
} else {
path.lineTo(currentX, currentY);
}
}
path.close();
canvas.drawPath(path, areaPaint);
}
示例3: drawRegion
import android.graphics.Path; //导入方法依赖的package包/类
/**
* 绘制区域
*
* @param canvas
*/
private void drawRegion(Canvas canvas) {
Path path = new Path();
valuePaint.setAlpha(255);
for (int i = 0; i < count; i++) {
double percent = data[i] / maxValue;
float x = (float) (centerX + radius * Math.cos(angle * i) * percent);
float y = (float) (centerY + radius * Math.sin(angle * i) * percent);
if (i == 0) {
path.moveTo(x, centerY);
} else {
path.lineTo(x, y);
}
//绘制小圆点
canvas.drawCircle(x, y, 10, valuePaint);
}
valuePaint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, valuePaint);
valuePaint.setAlpha(127);
//绘制填充区域
valuePaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawPath(path, valuePaint);
}
示例4: drawBubblePath
import android.graphics.Path; //导入方法依赖的package包/类
private void drawBubblePath(Canvas canvas, float triangleCenterX, float height, float width) {
final Path path = new Path();
int padding = 3;
final Rect rect = new Rect(padding, padding, (int) width - padding, (int) (height) - padding);
final float roundRectHeight = (height) / 2;
path.moveTo(rect.left + roundRectHeight, rect.top);
path.lineTo(rect.right - roundRectHeight, rect.top);
path.quadTo(rect.right, rect.top, rect.right, rect.top + roundRectHeight);
path.lineTo(rect.right, rect.bottom - roundRectHeight);
path.quadTo(rect.right, rect.bottom, rect.right - roundRectHeight, rect.bottom);
path.lineTo(triangleCenterX, height - padding);
path.lineTo(triangleCenterX, height - padding);
path.lineTo(triangleCenterX, height - padding);
path.lineTo(rect.left + roundRectHeight, rect.bottom);
path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - roundRectHeight);
path.lineTo(rect.left, rect.top + roundRectHeight);
path.quadTo(rect.left, rect.top, rect.left + roundRectHeight, rect.top);
path.close();
canvas.drawPath(path, settings.paintBubble);
}
示例5: onSizeChanged
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
path = new Path();
float halfWidth = (float) w / 2f;
float firstParam = (float) w * 0.1f;
float secondParam = (float) w * 0.8875f;
//Bézier Curves
path.moveTo(halfWidth, (float) w);
path.cubicTo(firstParam, (float) w, 0, secondParam, 0, halfWidth);
path.cubicTo(0, firstParam, firstParam, 0, halfWidth, 0);
path.cubicTo(secondParam, 0, (float) w, firstParam, (float) w, halfWidth);
path.cubicTo((float) w, secondParam, secondParam, (float) w, halfWidth, (float) w);
path.close();
}
示例6: run
import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void run() {
while (mIsDrawing) {
Canvas canvas = getHolder().lockCanvas();
if (canvas != null) {
canvas.drawColor(Color.WHITE);
for (int i = 0; i < mNumberOfWaves; i++) {
float halfHeight = mHeight / 2.0f;
float scaling = (float) KOF[i];
Path pth = new Path();
pth.moveTo(0, halfHeight);
float ampl = mCurrentAmpl;
float phi = i * (2 * mCurrentAmpl/mMaxAmpl) / 10 + t / 5f;
// float phi = i * ampl / 10f + t / 10f;
for (int x = 0; x < mWidth; x++) {
// We use a parable to scale the sinus wave, that has its peak in the middle of the view.
float v = (1.5f * (((float) x) / mWidth * 2) - 1.5f);
float y = (float) (scaling * ampl * Math.pow(K / (K + Math.pow(v, 4)), K) * Math.cos(4 * v - phi) + halfHeight + scaling*ampl*0.05f* Math.cos(3 * v));
pth.lineTo(x, y);
}
canvas.drawPath(pth, mPaints.get(i));
}
getHolder().unlockCanvasAndPost(canvas);
t++;
// try {
// Thread.sleep(50);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
}
}
示例7: 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;
}
示例8: paintTriplet
import android.graphics.Path; //导入方法依赖的package包/类
public void paintTriplet(Triplet triplet, Canvas canvas, Paint tripletPaint,
Junction junctionsArray[], Path tripletPath) {
int junctionNo1 = triplet.getJunctionNo1();
int junctionNo2 = triplet.getJunctionNo2();
int junctionNo3 = triplet.getJunctionNo3();
tripletPath.reset();
tripletPath.moveTo(junctionsArray[junctionNo1].getX(), junctionsArray[junctionNo1].getY());
tripletPath.lineTo(junctionsArray[junctionNo2].getX(), junctionsArray[junctionNo2].getY());
tripletPath.lineTo(junctionsArray[junctionNo3].getX(), junctionsArray[junctionNo3].getY());
canvas.drawPath(tripletPath, tripletPaint);
}
示例9: drawPolygon
import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void drawPolygon(final int[] x, final int[] y, final int length)
{
final Path path = new Path();
path.reset(); // only needed when reusing this path for a new build
path.moveTo(x[0], y[0]); // used for first point
for (int i = 1; i < length; i++)
{
path.lineTo(x[i], y[i]);
}
path.lineTo(x[0], y[0]);
this.paint.setStyle(Style.STROKE);
this.canvas.drawPath(path, this.paint);
}
示例10: makePathAndBoundingBox
import android.graphics.Path; //导入方法依赖的package包/类
private Path makePathAndBoundingBox(SVG.Ellipse obj) {
float cx = (obj.cx != null) ? obj.cx.floatValueX(this) : 0f;
float cy = (obj.cy != null) ? obj.cy.floatValueY(this) : 0f;
float rx = obj.rx.floatValueX(this);
float ry = obj.ry.floatValueY(this);
float left = cx - rx;
float top = cy - ry;
float right = cx + rx;
float bottom = cy + ry;
if (obj.boundingBox == null) {
obj.boundingBox = new Box(left, top, rx * 2, ry * 2);
}
float cpx = rx * BEZIER_ARC_FACTOR;
float cpy = ry * BEZIER_ARC_FACTOR;
Path p = new Path();
p.moveTo(cx, top);
p.cubicTo(cx + cpx, top, right, cy - cpy, right, cy);
p.cubicTo(right, cy + cpy, cx + cpx, bottom, cx, bottom);
p.cubicTo(cx - cpx, bottom, left, cy + cpy, left, cy);
p.cubicTo(left, cy - cpy, cx - cpx, top, cx, top);
p.close();
return p;
}
示例11: generateLinePath
import android.graphics.Path; //导入方法依赖的package包/类
/**
* 生成连线路径
*
* @param points 点集合(已被按下记录的点)
* @param eventX 事件X坐标(当前触摸位置)
* @param eventY 事件Y坐标(当前触摸位置)
*/
private Path generateLinePath(List<Point> points, float eventX, float eventY) {
Path path = new Path();
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
if (i == 0) {
path.moveTo(point.x, point.y);
} else {
path.lineTo(point.x, point.y);
}
}
path.lineTo(eventX, eventY);
return path;
}
示例12: getRightAlignedTriangle
import android.graphics.Path; //导入方法依赖的package包/类
private Path getRightAlignedTriangle(float x, float y, float r) {
Path path = new Path();
path.moveTo(x, y - r);
path.lineTo(x - r * 0.6f, y);
path.lineTo(x, y + r);
path.lineTo(x, y - r);
return path;
}
示例13: drawIndicator
import android.graphics.Path; //导入方法依赖的package包/类
/**
* 画指示器
*
* @param canvas
*/
private void drawIndicator(Canvas canvas) {
Path path = new Path();
path.moveTo(mWidth / 2 - mIndicatorHalfWidth, 0+H);
path.lineTo(mWidth / 2, mIndicatorHalfWidth+H);
path.lineTo(mWidth / 2 + mIndicatorHalfWidth, 0+H);
canvas.drawPath(path, mIndicatorViewPaint);
}
示例14: drawGridLine
import android.graphics.Path; //导入方法依赖的package包/类
@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();
}
示例15: createBottlePath
import android.graphics.Path; //导入方法依赖的package包/类
private Path createBottlePath(RectF bottleRect) {
float bottleneckWidth = bottleRect.width() * 0.3f;
float bottleneckHeight = bottleRect.height() * 0.415f;
float bottleneckDecorationWidth = bottleneckWidth * 1.1f;
float bottleneckDecorationHeight = bottleneckHeight * 0.167f;
Path path = new Path();
//draw the left side of the bottleneck decoration
path.moveTo(bottleRect.centerX() - bottleneckDecorationWidth * 0.5f, bottleRect.top);
path.quadTo(bottleRect.centerX() - bottleneckDecorationWidth * 0.5f - bottleneckWidth * 0.15f, bottleRect.top + bottleneckDecorationHeight * 0.5f,
bottleRect.centerX() - bottleneckWidth * 0.5f, bottleRect.top + bottleneckDecorationHeight);
path.lineTo(bottleRect.centerX() - bottleneckWidth * 0.5f, bottleRect.top + bottleneckHeight);
//draw the left side of the bottle's body
float radius = (bottleRect.width() - mStrokeWidth) / 2.0f;
float centerY = bottleRect.bottom - 0.86f * radius;
RectF bodyRect = new RectF(bottleRect.left, centerY - radius, bottleRect.right, centerY + radius);
path.addArc(bodyRect, 255, -135);
//draw the bottom of the bottle
float bottleBottomWidth = bottleRect.width() / 2.0f;
path.lineTo(bottleRect.centerX() - bottleBottomWidth / 2.0f, bottleRect.bottom);
path.lineTo(bottleRect.centerX() + bottleBottomWidth / 2.0f, bottleRect.bottom);
//draw the right side of the bottle's body
path.addArc(bodyRect, 60, -135);
//draw the right side of the bottleneck decoration
path.lineTo(bottleRect.centerX() + bottleneckWidth * 0.5f, bottleRect.top + bottleneckDecorationHeight);
path.quadTo(bottleRect.centerX() + bottleneckDecorationWidth * 0.5f + bottleneckWidth * 0.15f, bottleRect.top + bottleneckDecorationHeight * 0.5f,
bottleRect.centerX() + bottleneckDecorationWidth * 0.5f, bottleRect.top);
return path;
}