本文整理了Java中android.graphics.Path.addRect()
方法的一些代码示例,展示了Path.addRect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.addRect()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:addRect
暂无
代码示例来源:origin: rey5137/material
@Override
protected void onBoundsChange(Rect bounds) {
mBackgroundBounds.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
mBackground.reset();
mBackground.addRect(mBackgroundBounds, Direction.CW);
}
代码示例来源:origin: dinuscxj/LoadingDrawable
private Path createRiverPath(RectF arcBounds) {
if (mRiverPath != null) {
return mRiverPath;
}
mRiverPath = new Path();
RectF rectF = new RectF(arcBounds.centerX() - mRiverWidth / 2.0f, arcBounds.centerY() - mRiverHeight / 2.0f,
arcBounds.centerX() + mRiverWidth / 2.0f, arcBounds.centerY() + mRiverHeight / 2.0f);
rectF.inset(mRiverBankWidth / 2.0f, mRiverBankWidth / 2.0f);
mRiverPath.addRect(rectF, Path.Direction.CW);
return mRiverPath;
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void draw(@NonNull Canvas canvas) {
final Drawable drawable = ProgressDrawable.this;
final Rect bounds = drawable.getBounds();
final int width = bounds.width();
final int height = bounds.height();
final int r = Math.max(1, width / 20);
if (mWidth != width || mHeight != height) {
mPath.reset();
mPath.addCircle(width - r, height / 2, r, Path.Direction.CW);
mPath.addRect(width - 5 * r, height / 2 - r, width - r, height / 2 + r, Path.Direction.CW);
mPath.addCircle(width - 5 * r, height / 2, r, Path.Direction.CW);
mWidth = width;
mHeight = height;
}
canvas.save();
canvas.rotate(mProgressDegree, (width) / 2, (height) / 2);
for (int i = 0; i < 12; i++) {
mPaint.setAlpha((i+5) * 0x11);
canvas.rotate(30, (width) / 2, (height) / 2);
canvas.drawPath(mPath, mPaint);
}
canvas.restore();
}
代码示例来源:origin: steelkiwi/cropiwa
@Override
public Bitmap applyMaskTo(Bitmap croppedRegion) {
croppedRegion.setHasAlpha(true);
Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
RectF ovalRect = new RectF(0, 0, croppedRegion.getWidth(), croppedRegion.getHeight());
Path maskShape = new Path();
//This is similar to ImageRect\Oval
maskShape.addRect(ovalRect, Path.Direction.CW);
maskShape.addOval(ovalRect, Path.Direction.CCW);
Canvas canvas = new Canvas(croppedRegion);
canvas.drawPath(maskShape, maskPaint);
return croppedRegion;
}
}
代码示例来源:origin: igreenwood/SimpleCropView
private void drawOverlay(Canvas canvas) {
mPaintTranslucent.setAntiAlias(true);
mPaintTranslucent.setFilterBitmap(true);
mPaintTranslucent.setColor(mOverlayColor);
mPaintTranslucent.setStyle(Paint.Style.FILL);
Path path = new Path();
RectF overlayRect =
new RectF((float) Math.floor(mImageRect.left), (float) Math.floor(mImageRect.top),
(float) Math.ceil(mImageRect.right), (float) Math.ceil(mImageRect.bottom));
if (!mIsAnimating && (mCropMode == CropMode.CIRCLE || mCropMode == CropMode.CIRCLE_SQUARE)) {
path.addRect(overlayRect, Path.Direction.CW);
PointF circleCenter = new PointF((mFrameRect.left + mFrameRect.right) / 2,
(mFrameRect.top + mFrameRect.bottom) / 2);
float circleRadius = (mFrameRect.right - mFrameRect.left) / 2;
path.addCircle(circleCenter.x, circleCenter.y, circleRadius, Path.Direction.CCW);
canvas.drawPath(path, mPaintTranslucent);
} else {
path.addRect(overlayRect, Path.Direction.CW);
path.addRect(mFrameRect, Path.Direction.CCW);
canvas.drawPath(path, mPaintTranslucent);
}
}
代码示例来源:origin: rey5137/material
public void updateCorner(float radius){
mRadius = radius;
Rect bounds = getBounds();
mPath.reset();
if(radius == 0)
mPath.addRect(bounds.left, bounds.top, bounds.right, bounds.bottom, Path.Direction.CW);
else {
RectF rect = new RectF();
mPath.moveTo(bounds.left, bounds.top - radius);
rect.set(bounds.left, bounds.top, bounds.left + radius * 2, bounds.top + radius * 2);
mPath.arcTo(rect, 180, 90, false);
mPath.lineTo(bounds.right - radius, bounds.top);
rect.set(bounds.right - radius * 2, bounds.top, bounds.right, bounds.top + radius * 2);
mPath.arcTo(rect, 270, 90, false);
mPath.lineTo(bounds.right, bounds.bottom);
mPath.lineTo(bounds.left, bounds.bottom);
mPath.close();
}
invalidateSelf();
}
代码示例来源:origin: siyamed/android-shape-imageview
rectLeft = scaledTriangleHeight + x;
rectRight = resultWidth + rectLeft;
path.addRect(rectLeft, y, rectRight, resultHeight + y, Path.Direction.CW);
float imgRight = resultWidth + rectLeft;
rectRight = imgRight - scaledTriangleHeight;
path.addRect(rectLeft, y, rectRight, resultHeight + y, Path.Direction.CW);
path.moveTo(imgRight, centerY);
path.lineTo(rectRight, centerY - scaledTriangleHeight);
代码示例来源:origin: dinuscxj/LoadingDrawable
path.addRect(rectProgressRect, Path.Direction.CW);
代码示例来源:origin: rey5137/material
mHeaderBackground.reset();
if(mCornerRadius == 0)
mHeaderBackground.addRect(0, 0, mHeaderRealWidth, mHeaderRealHeight, Path.Direction.CW);
else{
mHeaderBackground.moveTo(0, mHeaderRealHeight);
mHeaderBackground.reset();
if(mCornerRadius == 0)
mHeaderBackground.addRect(0, 0, mHeaderRealWidth, mHeaderRealHeight, Path.Direction.CW);
else{
mHeaderBackground.moveTo(0, mHeaderRealHeight);
代码示例来源:origin: rey5137/material
mHeaderSecondaryBackground.reset();
if(mCornerRadius == 0)
mHeaderSecondaryBackground.addRect(0, 0, mHeaderRealWidth, mHeaderSecondaryHeight, Path.Direction.CW);
else{
mHeaderSecondaryBackground.moveTo(0, mHeaderSecondaryHeight);
mHeaderSecondaryBackground.reset();
if(mCornerRadius == 0)
mHeaderSecondaryBackground.addRect(0, 0, mHeaderRealWidth, mHeaderSecondaryHeight, Path.Direction.CW);
else{
mHeaderSecondaryBackground.moveTo(0, mHeaderSecondaryHeight);
代码示例来源:origin: jeasonlzy/ImagePicker
/** 绘制焦点框 */
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (Style.RECTANGLE == mStyle) {
mFocusPath.addRect(mFocusRect, Path.Direction.CCW);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight());
canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
canvas.drawColor(mMaskColor);
canvas.restore();
} else if (Style.CIRCLE == mStyle) {
float radius = Math.min((mFocusRect.right - mFocusRect.left) / 2, (mFocusRect.bottom - mFocusRect.top) / 2);
mFocusPath.addCircle(mFocusMidPoint.x, mFocusMidPoint.y, radius, Path.Direction.CCW);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight());
canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
canvas.drawColor(mMaskColor);
canvas.restore();
}
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBorderPaint.setAntiAlias(true);
canvas.drawPath(mFocusPath, mBorderPaint);
mFocusPath.reset();
}
代码示例来源:origin: jdamcd/android-crop
viewContext.getDrawingRect(viewDrawingRect);
path.addRect(new RectF(drawRect), Path.Direction.CW);
outlinePaint.setColor(highlightColor);
代码示例来源:origin: robolectric/robolectric
@Test
public void transform() {
Path path = new Path();
assertThat(path.isEmpty()).isTrue();
Path dst = new Path();
path.addRect(new RectF(LEFT, TOP, RIGHT, BOTTOM), Path.Direction.CW);
path.transform(new Matrix(), dst);
assertThat(dst.isEmpty()).isFalse();
}
代码示例来源:origin: florent37/DiagonalLayout
private void calculateLayout(int width, int height) {
rectView.reset();
rectView.addRect(0f, 0f, 1f * getWidth(), 1f * getHeight(), Path.Direction.CW);
代码示例来源:origin: robolectric/robolectric
@Test
public void addRect1() {
Path path = new Path();
assertThat(path.isEmpty()).isTrue();
RectF rect = new RectF(LEFT, TOP, RIGHT, BOTTOM);
path.addRect(rect, Path.Direction.CW);
assertThat(path.isEmpty()).isFalse();
}
代码示例来源:origin: florent37/ShapeOfView
private void calculateLayout(int width, int height) {
rectView.reset();
rectView.addRect(0f, 0f, 1f * getWidth(), 1f * getHeight(), Path.Direction.CW);
代码示例来源:origin: robolectric/robolectric
@Test
public void addRect2() {
Path path = new Path();
assertThat(path.isEmpty()).isTrue();
path.addRect(LEFT, TOP, RIGHT, BOTTOM, Path.Direction.CW);
assertThat(path.isEmpty()).isFalse();
}
代码示例来源:origin: siyamed/android-shape-imageview
Path p = new Path();
if (rx <= 0f && ry <= 0f) {
p.addRect(x, y, x + width, y + height, Path.Direction.CW);
} else {
rect.set(x, y, x + width, y + height);
代码示例来源:origin: florent37/ArcLayout
private void calculateLayout(int width, int height) {
rectView.reset();
rectView.addRect(0f, 0f, 1f * getWidth(), 1f * getHeight(), Path.Direction.CW);
代码示例来源:origin: weexteam/weex-hackernews
Path.Direction.CW);
} else {
path.addRect(rectF, Path.Direction.CW);
内容来源于网络,如有侵权,请联系作者删除!