本文整理汇总了Java中android.graphics.Path.addRoundRect方法的典型用法代码示例。如果您正苦于以下问题:Java Path.addRoundRect方法的具体用法?Java Path.addRoundRect怎么用?Java Path.addRoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.addRoundRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateClipPath
import android.graphics.Path; //导入方法依赖的package包/类
/**
* Update the path with which we'll clip this view
*/
private void updateClipPath() {
mPath = new Path();
TMP_RECT.set(
getLeft(),
getTop(),
getRight(),
getBottom());
// set the path
mPath.addRoundRect(
TMP_RECT,
mClipRadius,
mClipRadius,
Path.Direction.CW);
}
示例2: computePath
import android.graphics.Path; //导入方法依赖的package包/类
private void computePath(Rect bounds) {
final float currentScale = mCurrentScale;
final Path path = mPath;
final RectF rect = mRect;
final Matrix matrix = mMatrix;
path.reset();
int totalSize = Math.min(bounds.width(), bounds.height());
float initial = mClosedStateSize;
float currentSize = initial + ((float) totalSize - initial) * currentScale;
float halfSize = currentSize / 2f;
float inverseScale = 1f - currentScale;
float cornerSize = halfSize * inverseScale;
float[] corners = new float[]{halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize, cornerSize};
rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize);
path.addRoundRect(rect, corners, Path.Direction.CCW);
matrix.reset();
matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize);
matrix.postTranslate((bounds.width() - currentSize) / 2, 0);
float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
matrix.postTranslate(0, hDiff);
path.transform(matrix);
}
示例3: computePath
import android.graphics.Path; //导入方法依赖的package包/类
private void computePath(Rect bounds) {
final float currentScale = mCurrentScale;
final Path path = mPath;
final RectF rect = mRect;
final Matrix matrix = mMatrix;
path.reset();
int totalSize = Math.min(bounds.width(), bounds.height());
float initial = mClosedStateSize;
float destination = totalSize;
float currentSize = initial + (destination - initial) * currentScale;
float halfSize = currentSize / 2f;
float inverseScale = 1f - currentScale;
float cornerSize = halfSize * inverseScale;
float[] corners = new float[]{halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize, cornerSize};
rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize);
path.addRoundRect(rect, corners, Path.Direction.CCW);
matrix.reset();
matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize);
matrix.postTranslate((bounds.width() - currentSize) / 2, 0);
float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
matrix.postTranslate(0, hDiff);
path.transform(matrix);
}
示例4: getOutlineProvider
import android.graphics.Path; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ViewOutlineProvider getOutlineProvider() {
shadowpath = new Path();
if (config.getRadius() == 0) {
shadowpath = path;
} else {
rect = new Rect(0, 0, (int) width, (int) height);
RectF r = new RectF(rect);
shadowpath.addRoundRect(r, config.getRadius(), config.getRadius(), Path.Direction.CCW);
shadowpath.op(path, shadowpath, Path.Op.INTERSECT);
}
return new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
if (path.isConvex()) {
outline.setConvexPath(shadowpath);
}
}
};
}
示例5: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
Log.e("TAG", "onDraw");
if (getDrawable() == null) {
return;
}
setUpShader();
if (type == TYPE_ROUND) {
canvas.drawRoundRect(mRoundRect, mBorderRadius, mBorderRadius,
mBitmapPaint);
} else if (type == TYPE_LEFT_ROUND) {
float[] radii = {mBorderRadius, mBorderRadius, 0f, 0f, 0f, 0f, mBorderRadius, mBorderRadius};
Path path = new Path();
path.addRoundRect(mRoundRect, radii, Path.Direction.CW);
canvas.drawPath(path, mBitmapPaint);
} else {
canvas.drawCircle(mRadius, mRadius, mRadius, mBitmapPaint);
// drawSomeThing(canvas);
}
}
示例6: draw
import android.graphics.Path; //导入方法依赖的package包/类
public void draw(Canvas canvas) {
boolean positionChanged = adapterPositionChanged();
if (this.rippleOverlay) {
if (!positionChanged) {
this.rippleBackground.draw(canvas);
}
super.draw(canvas);
if (!positionChanged) {
if (this.rippleRoundedCorners != 0.0f) {
Path clipPath = new Path();
clipPath.addRoundRect(new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), this.rippleRoundedCorners, this.rippleRoundedCorners, Direction.CW);
canvas.clipPath(clipPath);
}
canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
return;
}
return;
}
if (!positionChanged) {
this.rippleBackground.draw(canvas);
canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
}
super.draw(canvas);
}
示例7: drawContent
import android.graphics.Path; //导入方法依赖的package包/类
private Bitmap drawContent(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
int borderWidth = mLayer.mBorder.mBorderWidth;
int topLeft = mLayer.mCornor.mTopLeftCornor;
int topRight = mLayer.mCornor.mTopRightCornor;
int bottomLeft = mLayer.mCornor.mBottomLeftCornor;
int bottomRight = mLayer.mCornor.mBottomRightCornor;
Path path = new Path();
path.addRoundRect(new RectF(borderWidth, borderWidth, width - borderWidth, height - borderWidth),
new float[]{topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft},
Path.Direction.CW);
canvas.drawPath(path, p);
return bitmap;
}
示例8: createCannulaBottomPath
import android.graphics.Path; //导入方法依赖的package包/类
private Path createCannulaBottomPath(RectF cannulaRect) {
RectF cannulaHeadRect = new RectF(cannulaRect.left, cannulaRect.bottom - 0.833f * cannulaRect.width(),
cannulaRect.right, cannulaRect.bottom);
Path path = new Path();
path.addRoundRect(cannulaHeadRect, mRectCornerRadius, mRectCornerRadius, Path.Direction.CCW);
return path;
}
示例9: drawEffectWithBorder
import android.graphics.Path; //导入方法依赖的package包/类
private void drawEffectWithBorder(Canvas canvas, Paint mTransparentPaint) {
RectF clipBounds = new RectF(canvas.getClipBounds());
Path mPath= new Path();
mPath.addRoundRect(clipBounds, mCornerRadius, Path.Direction.CW);
Bitmap result = Bitmap.createBitmap(getWidth(),getHeight(), Bitmap.Config.ARGB_8888);
Canvas tempCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
canvas.drawCircle(0,getHeight()/2,mCircleRadius,mTransparentPaint);
canvas.drawPath(mPath, paint);
paint.setXfermode(null);
//Draw result after performing masking
canvas.drawBitmap(result, 0, 0, new Paint());
}
示例10: getContentPath
import android.graphics.Path; //导入方法依赖的package包/类
public
@NonNull
Path getContentPath(int viewTopPadding,
int viewRightPadding,
int viewBottomPadding,
int viewLeftPadding,
@NonNull RectF contentBox) {
RectF rectForBorderOutline = new RectF();
Path contentClip = new Path();
rectForBorderOutline.set(contentBox);
if (mBorderRadius != null) {
prepareBorderRadius();
float topLeftRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_LEFT_RADIUS);
float topRightRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_RIGHT_RADIUS);
float bottomRightRadius = getBorderRadius(mOverlappingBorderRadius,
BORDER_BOTTOM_RIGHT_RADIUS);
float bottomLeftRadius = getBorderRadius(mOverlappingBorderRadius,
BORDER_BOTTOM_LEFT_RADIUS);
contentClip.addRoundRect(rectForBorderOutline,
new float[]{
topLeftRadius - viewLeftPadding,
topLeftRadius - viewTopPadding,
topRightRadius - viewRightPadding,
topRightRadius - viewTopPadding,
bottomRightRadius - viewRightPadding,
bottomRightRadius - viewBottomPadding,
bottomLeftRadius - viewLeftPadding,
bottomLeftRadius - viewBottomPadding
},
Path.Direction.CW);
} else {
contentClip.addRect(rectForBorderOutline, Path.Direction.CW);
}
return contentClip;
}
示例11: prepareBorderPath
import android.graphics.Path; //导入方法依赖的package包/类
private void prepareBorderPath(int topPadding,
int rightPadding,
int bottomPadding,
int leftPadding,
@NonNull RectF rectF,
@NonNull Path path) {
if (mBorderRadius != null) {
prepareBorderRadius(rectF);
float topLeftRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_LEFT_RADIUS);
float topRightRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_RIGHT_RADIUS);
float bottomRightRadius = getBorderRadius(mOverlappingBorderRadius,
BORDER_BOTTOM_RIGHT_RADIUS);
float bottomLeftRadius = getBorderRadius(mOverlappingBorderRadius,
BORDER_BOTTOM_LEFT_RADIUS);
path.addRoundRect(
rectF,
new float[]{
topLeftRadius - leftPadding,
topLeftRadius - topPadding,
topRightRadius - rightPadding,
topRightRadius - topPadding,
bottomRightRadius - rightPadding,
bottomRightRadius - bottomPadding,
bottomLeftRadius - leftPadding,
bottomLeftRadius - bottomPadding
},
Path.Direction.CW);
} else {
path.addRect(rectF, Path.Direction.CW);
}
}
示例12: buildBoundPath
import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void buildBoundPath(Path boundPath){
boundPath.reset();
final int width = getWidth();
final int height = getHeight();
radius = Math.min(radius, Math.min(width, height) * 0.5f);
RectF rect = new RectF(0, 0, width, height);
boundPath.addRoundRect(rect , radius, radius, Direction.CW);
}
示例13: buildBorderPath
import android.graphics.Path; //导入方法依赖的package包/类
@Override
public void buildBorderPath(Path borderPath) {
borderPath.reset();
final float halfBorderWidth = getBorderWidth() * 0.5f;
final int width = getWidth();
final int height = getHeight();
radius = Math.min(radius, Math.min(width, height) * 0.5f);
RectF rect = new RectF(halfBorderWidth, halfBorderWidth,
width - halfBorderWidth, height - halfBorderWidth);
borderPath.addRoundRect(rect , radius, radius, Direction.CW);
}
示例14: updatePath
import android.graphics.Path; //导入方法依赖的package包/类
protected final void updatePath(Path path, float correction) {
path.reset();
TMP_RECT.set(
getLeft() + correction,
getTop() + correction,
getRight() - correction,
getBottom() - correction);
path.addRoundRect(
TMP_RECT,
mBorderRadius,
mBorderRadius,
Path.Direction.CW);
}
示例15: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 需要剪切应显示视图的其余部分
Path path = new Path();
path.addRoundRect(
new RectF(0, 0, canvas.getWidth(), canvas.getHeight()),
_PST.dpToPx(cornerRadius),
_PST.dpToPx(cornerRadius),
Path.Direction.CW
);
canvas.clipPath(path, Region.Op.REPLACE);
}