本文整理汇总了Java中android.graphics.Path.addCircle方法的典型用法代码示例。如果您正苦于以下问题:Java Path.addCircle方法的具体用法?Java Path.addCircle怎么用?Java Path.addCircle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.addCircle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawAuxLines
import android.graphics.Path; //导入方法依赖的package包/类
private void drawAuxLines(Canvas canvas) {
Path path = new Path();
path.moveTo(B.x, B.y);
path.addCircle(O.x, O.y, Math.abs(O.x), Path.Direction.CW);
canvas.drawPath(path, mAuxPaint);
path.moveTo(O.x, E.y);
path.lineTo(O.x, F.y);
path.moveTo(E.x, O.y);
path.lineTo(F.x, O.y);
path.addRect(E.x, E.y, F.x, F.y, Path.Direction.CW);
canvas.drawPath(path, mAuxPaint);
path.moveTo(O.x, O.y);
path.lineTo(C.x, C.y);
canvas.drawPath(path, mAuxPaint);
}
示例2: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
/**
* Path同样也给我们封装好了一些路径效果,例如圆形,矩形等等,跟canvas.drawXX比较类似,这里就简单介绍下
*
* addArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle)
* 添加弧线到路径
*
* addCircle(float x, float y, float radius, Path.Direction dir) 添加圆到路径
*
* addOval(float left, float top, float right, float bottom, Path.Direction dir) 添加椭圆到路径
*
* addRect(float left, float top, float right, float bottom, Path.Direction dir) 添加矩形到路径
*
* 上面的Path.Direction dir参数用来指定绘制时是顺时针还是逆时针,Path.Direction.CCW和Path.Direction.CW分别代表逆时针和顺时针,
* 顺时针和逆时针主要的作用在于不同的时针方向也就决定了不同的路径起始点和终点,其他的参数跟canvas.drawXX是一样的
*/
@Override protected void onDraw(Canvas canvas) {
//设置绘制风格
setViewPaint();
//构建path
Path path = new Path();
//添加弧形到path
path.addArc(100, 100, 300, 300, 0, 270);
//添加圆形到path
path.addCircle(200, 500, 100, Path.Direction.CCW);
//添加矩形到path
path.addRect(100, 700, 300, 800, Path.Direction.CW);
//添加椭圆到path
path.addOval(100, 900, 300, 1000, Path.Direction.CCW);
//绘制path
canvas.drawPath(path, paint);
}
示例3: GetBitmapClippedCircle
import android.graphics.Path; //导入方法依赖的package包/类
public Bitmap GetBitmapClippedCircle(Bitmap bitmap) {
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Path path = new Path();
path.addCircle(
(float) (width / 2)
, (float) (height / 2)
, (float) Math.min(width, (height / 2))
, Path.Direction.CCW);
final Canvas canvas = new Canvas(outputBitmap);
canvas.clipPath(path);
canvas.drawBitmap(bitmap, 0, 0, null);
bitmap.recycle();
return outputBitmap;
}
示例4: getRoundedShape
import android.graphics.Path; //导入方法依赖的package包/类
public Bitmap getRoundedShape(Bitmap scaleBitmapImage) {
int targetWidth = getWidth()-2*getBorderThickness();
int targetHeight = getHeight()-2*getBorderThickness();
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth,
targetHeight,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(((float) targetWidth - 1) / 2,
((float) targetHeight - 1) / 2,
(Math.min(((float) targetWidth),
((float) targetHeight)) / 2),
Path.Direction.CCW);
canvas.clipPath(path);
canvas.drawBitmap(scaleBitmapImage,
new Rect(0, 0, scaleBitmapImage.getWidth(),
scaleBitmapImage.getHeight()),
new Rect(0, 0, targetWidth, targetHeight), null);
return targetBitmap;
}
示例5: clipToCircle
import android.graphics.Path; //导入方法依赖的package包/类
public static Bitmap clipToCircle(Bitmap bitmap) {
if (bitmap == null) {
return null;
}
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Path path = new Path();
path.addCircle((float) (width / 2), (float) (height / 2),
(float) Math.min(width, (height / 2)), Path.Direction.CCW);
final Canvas canvas = new Canvas(outputBitmap);
canvas.clipPath(path);
canvas.drawBitmap(bitmap, 0, 0, null);
return outputBitmap;
}
示例6: drawHighlightCircle
import android.graphics.Path; //导入方法依赖的package包/类
public void drawHighlightCircle(Canvas c,
MPPointF point,
float innerRadius,
float outerRadius,
int fillColor,
int strokeColor,
float strokeWidth) {
c.save();
outerRadius = Utils.convertDpToPixel(outerRadius);
innerRadius = Utils.convertDpToPixel(innerRadius);
if (fillColor != ColorTemplate.COLOR_NONE) {
Path p = mDrawHighlightCirclePathBuffer;
p.reset();
p.addCircle(point.x, point.y, outerRadius, Path.Direction.CW);
if (innerRadius > 0.f) {
p.addCircle(point.x, point.y, innerRadius, Path.Direction.CCW);
}
mHighlightCirclePaint.setColor(fillColor);
mHighlightCirclePaint.setStyle(Paint.Style.FILL);
c.drawPath(p, mHighlightCirclePaint);
}
if (strokeColor != ColorTemplate.COLOR_NONE) {
mHighlightCirclePaint.setColor(strokeColor);
mHighlightCirclePaint.setStyle(Paint.Style.STROKE);
mHighlightCirclePaint.setStrokeWidth(Utils.convertDpToPixel(strokeWidth));
c.drawCircle(point.x, point.y, outerRadius, mHighlightCirclePaint);
}
c.restore();
}
示例7: testPathForCan
import android.graphics.Path; //导入方法依赖的package包/类
private void testPathForCan(Canvas canvas) {
canvas.translate(mWidth / 2, mHeight / 2); // 移动坐标系到屏幕中心
// canvas.scale(1, -1); // <-- 注意 翻转y坐标轴
Path path = new Path();
Path src = new Path();
path.addRect(-200, -200, 200, 200, Path.Direction.CW);
src.addCircle(0, 0, 100, Path.Direction.CW);
path.addPath(src, 0, 200);
paint.setColor(Color.BLACK); // 绘制合并后的路径
canvas.drawPath(path, paint);
}
示例8: drawBackground
import android.graphics.Path; //导入方法依赖的package包/类
protected void drawBackground(Canvas canvas) {
Paint bgPaint = new Paint();
bgPaint.setColor(this.mCircleBackground);
int radius = getViewRadius() - ((this.mDividerWidth * 3) / 2);
canvas.drawCircle((float) getCenterX(), (float) getCenterY(), (float) radius, bgPaint);
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
Paint paint = new Paint();
paint.setColor(this.mCircleGray);
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(1.0f);
canvas.drawPath(path, paint);
}
示例9: drawCircle
import android.graphics.Path; //导入方法依赖的package包/类
private void drawCircle(Canvas canvas) {
Paint textPaint = new Paint();
textPaint.setColor(this.mCircleWhite);
textPaint.setAntiAlias(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
float textHeight = (float) ViewUtils.getTextHeight(textPaint);
float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
int radius = (int) (((float) getViewRadius()) - (2.6f * ((float) this.mDividerWidth)));
FontMetricsInt fmi = textPaint.getFontMetricsInt();
float textRadius = (float) (radius - (Math.abs(fmi.bottom + fmi.top) / 2));
RectF oval = new RectF((float) (getCenterX() - radius), (float) (getCenterY() - radius),
(float) (getCenterX() + radius), (float) (getCenterY() + radius));
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), textRadius, Direction.CW);
Paint circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setStrokeWidth(16.0f + textHeight);
circlePaint.setStyle(Style.STROKE);
if (this.mDividerIndicator.size() == 0) {
circlePaint.setStrokeCap(Cap.ROUND);
circlePaint.setColor(this.mCircleGray);
canvas.drawArc(oval, 135.0f, 270.0f, false, circlePaint);
return;
}
circlePaint.setStrokeCap(Cap.ROUND);
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(0), oval, perAngle,
textRadius, path, textPaint, circlePaint);
Canvas canvas2 = canvas;
drawCircleContent(canvas2, (IndicatorItem) this.mDividerIndicator.get(this
.mDividerIndicator.size() - 1), oval, perAngle, textRadius, path, textPaint,
circlePaint);
circlePaint.setStrokeCap(Cap.BUTT);
for (int i = 1; i < this.mDividerIndicator.size() - 1; i++) {
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(i), oval,
perAngle, textRadius, path, textPaint, circlePaint);
}
}
示例10: computeCircleAndLinePath
import android.graphics.Path; //导入方法依赖的package包/类
/**
* 计算点圆与线轨迹
*/
private void computeCircleAndLinePath() {
circlePaths = new Path[CIRCLE_SIZE];
linePaths = new Path[CIRCLE_SIZE - 1];
for (int i = 0; i < CIRCLE_SIZE; i++) {
Path circlePath = new Path();
//计算每个圆点的中心点
int mCircleCenterX = DimensUtils.getMetricsWidth(getContext()) / 2;
int mCircleCenterY = getPaddingTop() + circleRadius;
//计算圆点路径
circlePath.addCircle(mCircleCenterX, mCircleCenterY, circleRadius, Path.Direction.CCW);
circlePaths[i] = circlePath;
if (i == CIRCLE_SIZE - 1) {
continue;
}
//计算线段路径
Path linePath = new Path();
//计算线段起始点
int mlineStartX = mCircleCenterX + (circleRadius + circleStokeWidth) / 2;
int mlineEndX = (i + 1) * DimensUtils.getMetricsWidth(getContext()) / 5;
linePath.moveTo(mlineStartX, mCircleCenterY);
linePath.lineTo(mlineEndX, mCircleCenterY);
linePaths[i] = linePath;
}
}
示例11: updateBounds
import android.graphics.Path; //导入方法依赖的package包/类
private void updateBounds() {
final Rect b = getBounds();
final int width = (int) ((float) b.width() * getLevel() / MAX_LEVEL);
final float radius = b.height() / 2f;
mVisibleRect.set(b.left, b.top, b.left + width, b.height());
// draw round to head of progressbar. I know it looks stupid, don't blame me now.
mPath = new Path();
mPath.addRect(b.left, b.top, b.left + width - radius, b.height(), Path.Direction.CCW);
mPath.addCircle(b.left + width - radius, radius, radius, Path.Direction.CCW);
}
示例12: drawPath1
import android.graphics.Path; //导入方法依赖的package包/类
private void drawPath1(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
Path path = new Path();
path.addCircle(300, 300, 200, Path.Direction.CW);
canvas.drawPath(path, paint);
}
示例13: makePointerPath
import android.graphics.Path; //导入方法依赖的package包/类
public static Path makePointerPath(Context context) {
Path pointerPath = new Path();
final float radiusPx = dipToPixels(context, POINTER_RADIUS_DIP);
pointerPath.addCircle(0, 0, radiusPx, Path.Direction.CW);
return pointerPath;
}
示例14: drawRepeatBarline
import android.graphics.Path; //导入方法依赖的package包/类
void drawRepeatBarline(Canvas canvas, StaffLayout staffLayout, BarLayout.Barline barline, BarLayout.BarlineLoc loc) {
final float thick = kThickBarlineThicknessTenths * staffLayout.tenthSize;
final float thin = kThinBarlineThicknessTenths * staffLayout.tenthSize;
final float gap = kBarlineSeparationTenths * staffLayout.tenthSize;
final float dotGap = kRepeatDotsBarlineGap * staffLayout.tenthSize;
final float dotRadius = kRepeatDotRadius * staffLayout.tenthSize;
final float dotOffset = kRepeatDotOffset * staffLayout.tenthSize;
final float margin = kBarlineBackgroundMargin * staffLayout.tenthSize;
// construct for repeat double barline - left or right
Path path = new Path();
Paint paint = new Paint();
paint.setARGB(255, 0, 0, 255);
RectF thickBarline = new RectF(barline.rect.centerX()-thick/2, barline.rect.top, barline.rect.centerX()+thick/2, barline.rect.bottom);
path.addRect(thickBarline, Path.Direction.CW);
float thinLeft;
float dotCentrex;
if (loc == BarLayout.BarlineLoc.left) {
thinLeft = thickBarline.right + gap;
dotCentrex = thinLeft + thin + dotGap + dotRadius;
} else {
thinLeft = thickBarline.left - gap - thin;
dotCentrex = thinLeft - dotGap - dotRadius;
}
RectF thinBarline = new RectF(thinLeft, barline.rect.top, thinLeft + thin, barline.rect.bottom);
path.addRect(thinBarline, Path.Direction.CW);
// repeat dots on each staff
for (StaffLayout.Staff staff : staffLayout.staves) {
float centreStaffY = staff.staffRect.centerY();
if (centreStaffY + dotOffset < getHeight()) { // ensure we don't add dots below bottom of view height
path.addCircle(dotCentrex, centreStaffY - dotOffset, dotRadius, Path.Direction.CW);
path.addCircle(dotCentrex, centreStaffY + dotOffset, dotRadius, Path.Direction.CW);
}
}
// paint translucent white background
Path bgPath = new Path();
Paint bgPaint = new Paint();
bgPaint.setARGB(180, 255, 255, 255);
// background overlaps foreground by margin
if (loc == BarLayout.BarlineLoc.left)
bgPath.addRect(new RectF(thickBarline.left - margin, thickBarline.top-margin, dotCentrex+dotRadius+margin, thickBarline.bottom + margin), Path.Direction.CW);
else
bgPath.addRect(new RectF(dotCentrex - dotRadius - margin, thickBarline.top-margin, thickBarline.right + margin, thickBarline.bottom + margin), Path.Direction.CW);
canvas.drawPath(bgPath, bgPaint);
// paint repeat double barline in blue
canvas.drawPath(path, paint);
}
示例15: drawEditFrame
import android.graphics.Path; //导入方法依赖的package包/类
private void drawEditFrame(Canvas canvas) {
if (!mIsCropEnabled) return;
if (mCropMode == CropMode.CIRCLE) {
mPaintTransparent.setFilterBitmap(true);
mPaintTransparent.setColor(mOverlayColor);
mPaintTransparent.setStyle(Paint.Style.FILL);
Path path = new Path();
path.addRect(mImageRect.left, mImageRect.top, mImageRect.right, mImageRect.bottom, Path.Direction.CW);
path.addCircle((mFrameRect.left + mFrameRect.right) / 2, (mFrameRect.top + mFrameRect.bottom) / 2, (mFrameRect.right - mFrameRect.left) / 2, Path.Direction.CCW);
canvas.drawPath(path, mPaintTransparent);
} else {
mPaintTransparent.setFilterBitmap(true);
mPaintTransparent.setColor(mOverlayColor);
mPaintTransparent.setStyle(Paint.Style.FILL);
canvas.drawRect(mImageRect.left, mImageRect.top, mImageRect.right, mFrameRect.top, mPaintTransparent);
canvas.drawRect(mImageRect.left, mFrameRect.bottom, mImageRect.right, mImageRect.bottom, mPaintTransparent);
canvas.drawRect(mImageRect.left, mFrameRect.top, mFrameRect.left, mFrameRect.bottom, mPaintTransparent);
canvas.drawRect(mFrameRect.right, mFrameRect.top, mImageRect.right, mFrameRect.bottom, mPaintTransparent);
}
mPaintFrame.setAntiAlias(true);
mPaintFrame.setFilterBitmap(true);
mPaintFrame.setStyle(Paint.Style.STROKE);
mPaintFrame.setColor(mFrameColor);
mPaintFrame.setStrokeWidth(mFrameStrokeWeight);
canvas.drawRect(mFrameRect.left, mFrameRect.top, mFrameRect.right, mFrameRect.bottom, mPaintFrame);
if (mShowGuide) {
mPaintFrame.setColor(mGuideColor);
mPaintFrame.setStrokeWidth(mGuideStrokeWeight);
float h1 = mFrameRect.left + (mFrameRect.right - mFrameRect.left) / 3.0f;
float h2 = mFrameRect.right - (mFrameRect.right - mFrameRect.left) / 3.0f;
float v1 = mFrameRect.top + (mFrameRect.bottom - mFrameRect.top) / 3.0f;
float v2 = mFrameRect.bottom - (mFrameRect.bottom - mFrameRect.top) / 3.0f;
canvas.drawLine(h1, mFrameRect.top, h1, mFrameRect.bottom, mPaintFrame);
canvas.drawLine(h2, mFrameRect.top, h2, mFrameRect.bottom, mPaintFrame);
canvas.drawLine(mFrameRect.left, v1, mFrameRect.right, v1, mPaintFrame);
canvas.drawLine(mFrameRect.left, v2, mFrameRect.right, v2, mPaintFrame);
}
if (mShowHandle) {
mPaintFrame.setStyle(Paint.Style.FILL);
mPaintFrame.setColor(mHandleColor);
canvas.drawCircle(mFrameRect.left, mFrameRect.top, mHandleSize, mPaintFrame);
canvas.drawCircle(mFrameRect.right, mFrameRect.top, mHandleSize, mPaintFrame);
canvas.drawCircle(mFrameRect.left, mFrameRect.bottom, mHandleSize, mPaintFrame);
canvas.drawCircle(mFrameRect.right, mFrameRect.bottom, mHandleSize, mPaintFrame);
}
}