float radius = 20; final RectF oval = new RectF(); oval.set(point1.x - radius, point1.y - radius, point1.x + radius, point1.y+ radius); Path myPath = new Path(); myPath.arcTo(oval, startAngle, -(float) sweepAngle, true);
path.arcTo(right - 2*rx, top, right, top + 2*ry, 0, -90, false); //top-right-corner path.rLineTo(-widthMinusCorners, 0); path.arcTo(left, top, left + 2*rx, top + 2*ry, 270, -90, false);//top-left corner. path.rLineTo(0, heightMinusCorners); if (conformToOriginalPost) { path.arcTo(left, bottom - 2 * ry, left + 2 * rx, bottom, 180, -90, false); //bottom-left corner path.rLineTo(widthMinusCorners, 0); path.arcTo(right - 2 * rx, bottom - 2 * ry, right, bottom, 90, -90, false); //bottom-right corner
segmentPath.moveTo((float)(cx + rInn * cos(start)), (float)(cy + rInn * sin(start))); segmentPath.lineTo((float)(cx + rOut * cos(start)), (float)(cy + rOut * sin(start))); segmentPath.arcTo(outerRect, startAngle, sweepAngle); double end = toRadians(startAngle + sweepAngle); segmentPath.lineTo((float)(cx + rInn * cos(end)), (float)(cy + rInn * sin(end))); segmentPath.arcTo(innerRect, startAngle + sweepAngle, -sweepAngle); if (fill != null) { canvas.drawPath(segmentPath, fill);
float radius = 20; final RectF oval = new RectF(); oval.set(point1.x - radius, point1.y - radius, point1.x + radius, point1.y+ radius); Path myPath = new Path(); myPath.arcTo(oval, startAngle, -(float) sweepAngle, true);
Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.rgb(255, 139, 40)); float x = 500, y = 500, r = 500, angle = 50; Path path = new Path(); path.arcTo(new RectF(x, y-r, x+2*r, y+r),180,angle); path.lineTo((float) (x - r * (1 - Math.cos(Math.toRadians(angle)))), (float) (y - r * Math.sin(Math.toRadians(angle)))); path.arcTo(new RectF(x - 2 * r, y - r, x, y + r), -angle, angle); path.close(); canvas.drawPath(path,paint);
Point center = new Point(canvas.getWidth()/2, canvas.getHeight()/2); int inner_radius = 100; int outer_radius = 150; int arc_sweep = 90; int arc_ofset = 30; RectF outer_rect = new RectF(center.x-outer_radius, center.y-outer_radius, center.x+outer_radius, center.y+outer_radius); RectF inner_rect = new RectF(center.x-inner_radius, center.y-inner_radius, center.x+inner_radius, center.y+inner_radius); Path path = new Path(); path.arcTo(outer_rect, arc_ofset, arc_sweep); path.arcTo(inner_rect, arc_ofset + arc_sweep, -arc_sweep); path.close(); Paint fill = new Paint(); fill.setColor(Color.GREEN); canvas.drawPath(path, fill); Paint border = new Paint(); border.setStyle(Paint.Style.STROKE); border.setStrokeWidth(2); canvas.drawPath(path, border);
RectF rectangle = new RectF(60f, 60f, 480f, 480f); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(0x40000000); paint.setStyle(Paint.Style.FILL); float strokeWidth = 120; float startAngle = 225f; float sweepAngle = 315f; RectF pathRect = new RectF(); Path path = new Path(); float s = strokeWidth / 2; pathRect.left = rectangle.left - s; pathRect.right = rectangle.right + s; pathRect.top = rectangle.top - s; pathRect.bottom = rectangle.bottom + s; path.arcTo(pathRect, startAngle, sweepAngle); pathRect.left = rectangle.left + s; pathRect.right = rectangle.right - s; pathRect.top = rectangle.top + s; pathRect.bottom = rectangle.bottom - s; path.arcTo(pathRect, startAngle + sweepAngle, -sweepAngle); path.close(); canvas.drawPath(path, paint);
Path path = new Path(); // Set the starting position of the path to (0,0). path.moveTo(0, 0); path.arcTo(...); //draw your arc here path.circleTo(); //draw a small circle here at the end of arc
//get the drawing rectangle (calculate inner/outer border width) RectF sr = new RectF(); sr.set(cr.left + innerBorderScaledSize / 2f, cr.top + innerBorderScaledSize / 2f, cr.right - innerBorderScaledSize / 2f, (cr.top - innerBorderScaledSize / 2f + cr.bottom - innerBorderScaledSize / 2f) / 2f); RectF cor = new RectF(); cor.set(sr.left, sr.top, sr.left + cornerScaledRaius, sr.top + cornerScaledRaius); //here the interesting part: draw the shape Path path = new Path(); path.reset(); path.moveTo(sr.left, sr.bottom); path.lineTo(sr.left, sr.top + cornerScaledRaius); path.arcTo(cor, 180, 90); cor.set(sr.right - cornerScaledRaius, sr.top, sr.right, sr.top + cornerScaledRaius); path.arcTo(cor, 270, 90); path.lineTo(sr.right, sr.bottom); path.close(); canvas.drawPath(path, shinePaint);
int sweepAngle = 360 - openSize; path.arcTo(rectf, startAngle, sweepAngle); path.lineTo(linex, liney); path.close();
mPath.reset(); mPath.moveTo(0, w / 2f); mPath.arcTo(mOval, 180, 180); mPath.rLineTo(-dx, 0); mOval.inset(dx, dx);
clipPath.setLastPoint(getWidth() / 2, getHeight() / 2); clipPath.lineTo(getWidth() / 2, getHeight()); clipPath.arcTo(fullRect, -90, angle); clipPath.lineTo(getWidth() / 2, getHeight() / 2); c.clipPath(clipPath);