本文整理了Java中android.graphics.Path.computeBounds()
方法的一些代码示例,展示了Path.computeBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.computeBounds()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:computeBounds
暂无
代码示例来源:origin: airbnb/lottie-android
/**
* For testing purposes only. DO NOT USE IN PRODUCTION.
*/
public static Bitmap renderPath(Path path) {
RectF bounds = new RectF();
path.computeBounds(bounds, false);
Bitmap bitmap = Bitmap.createBitmap((int) bounds.right, (int) bounds.bottom, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new LPaint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
canvas.drawPath(path, paint);
return bitmap;
}
}
代码示例来源:origin: tarek360/RichPath
public static float getPathHeight(Path path) {
RectF rect = new RectF();
path.computeBounds(rect, true);
return rect.height();
}
代码示例来源:origin: tarek360/RichPath
public static float getPathWidth(Path path) {
RectF rect = new RectF();
path.computeBounds(rect, true);
return rect.width();
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
path.reset();
for (int i = 0; i < paths.size(); i++) {
path.addPath(paths.get(i).getPath(), parentMatrix);
}
path.computeBounds(outBounds, false);
// Add padding to account for rounding errors.
outBounds.set(
outBounds.left - 1,
outBounds.top - 1,
outBounds.right + 1,
outBounds.bottom + 1
);
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
path.reset();
for (int i = 0; i < paths.size(); i++) {
this.path.addPath(paths.get(i).getPath(), parentMatrix);
}
path.computeBounds(outBounds, false);
// Add padding to account for rounding errors.
outBounds.set(
outBounds.left - 1,
outBounds.top - 1,
outBounds.right + 1,
outBounds.bottom + 1
);
}
代码示例来源:origin: tarek360/RichPath
public static void setPathRotation(Path path, float rotation) {
RectF rect = new RectF();
path.computeBounds(rect, true);
setPathRotation(path, rotation, rect.centerX(), rect.centerY());
}
代码示例来源:origin: totond/TextPathView
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mFontPath.computeBounds(mPathBounds, true);
}
代码示例来源:origin: tarek360/RichPath
public static void setPathScaleX(Path path, float scale) {
RectF rect = new RectF();
path.computeBounds(rect, true);
setPathScaleX(path, scale, rect.centerX(), rect.centerY());
}
代码示例来源:origin: tarek360/RichPath
public static void setPathScaleY(Path path, float scale) {
RectF rect = new RectF();
path.computeBounds(rect, true);
setPathScaleY(path, scale, rect.centerX(), rect.centerY());
}
代码示例来源:origin: siyamed/android-shape-imageview
PathInfo(Path path, float width, float height) {
this.path = path;
float tmpWidth = width;
float tmpHeight = height;
RectF bounds = new RectF();
path.computeBounds(bounds, true);
if(width <= 0 && height <= 0) {
tmpWidth = (float) Math.ceil(bounds.width());
tmpHeight = (float) Math.ceil(bounds.height());
path.offset(-1 * (float) Math.floor(bounds.left),
-1 * (float) Math.round(bounds.top));
}
this.width = tmpWidth;
this.height = tmpHeight;
}
代码示例来源:origin: tarek360/RichPath
public static void setPathWidth(Path path, float width) {
RectF src = new RectF();
path.computeBounds(src, true);
Matrix resizeMatrix = new Matrix();
RectF bounds = new RectF(src.left, src.top, src.left + width, src.bottom);
resizeMatrix.setRectToRect(src, bounds, Matrix.ScaleToFit.FILL);
path.transform(resizeMatrix);
}
代码示例来源:origin: airbnb/lottie-android
@Override public void getBounds(RectF outBounds, Matrix parentMatrix, boolean applyParents) {
L.beginSection("StrokeContent#getBounds");
path.reset();
for (int i = 0; i < pathGroups.size(); i++) {
PathGroup pathGroup = pathGroups.get(i);
for (int j = 0; j < pathGroup.paths.size(); j++) {
path.addPath(pathGroup.paths.get(j).getPath(), parentMatrix);
}
}
path.computeBounds(rect, false);
float width = ((FloatKeyframeAnimation) widthAnimation).getFloatValue();
rect.set(rect.left - width / 2f, rect.top - width / 2f,
rect.right + width / 2f, rect.bottom + width / 2f);
outBounds.set(rect);
// Add padding to account for rounding errors.
outBounds.set(
outBounds.left - 1,
outBounds.top - 1,
outBounds.right + 1,
outBounds.bottom + 1
);
L.endSection("StrokeContent#getBounds");
}
代码示例来源:origin: tarek360/RichPath
public static void setPathHeight(Path path, float height) {
RectF src = new RectF();
path.computeBounds(src, true);
Matrix resizeMatrix = new Matrix();
RectF bounds = new RectF(src.left, src.top, src.right, src.top + height);
resizeMatrix.setRectToRect(src, bounds, Matrix.ScaleToFit.FILL);
path.transform(resizeMatrix);
}
代码示例来源:origin: tarek360/RichPath
public static void resizePath(Path path, float width, float height) {
RectF bounds = new RectF(0, 0, width, height);
RectF src = new RectF();
path.computeBounds(src, true);
Matrix resizeMatrix = new Matrix();
resizeMatrix.setRectToRect(src, bounds, Matrix.ScaleToFit.FILL);
path.transform(resizeMatrix);
}
代码示例来源:origin: mikepenz/Android-Iconics
/**
* Update the TextSize
*/
private void updateTextSize(@NonNull Rect viewBounds) {
float textSize = (float) viewBounds.height() * (mRespectFontBounds ? 1 : 2);
mIconBrush.getPaint().setTextSize(textSize);
String textValue = mIcon != null ? String.valueOf(mIcon.getCharacter()) : String.valueOf(mPlainIcon);
mIconBrush.getPaint().getTextPath(textValue, 0, textValue.length(), 0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
if (!mRespectFontBounds) {
float deltaWidth = ((float) mPaddingBounds.width() / mPathBounds.width());
float deltaHeight = ((float) mPaddingBounds.height() / mPathBounds.height());
float delta = (deltaWidth < deltaHeight) ? deltaWidth : deltaHeight;
textSize *= delta;
mIconBrush.getPaint().setTextSize(textSize);
mIconBrush.getPaint().getTextPath(textValue, 0, textValue.length(), 0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
}
}
代码示例来源:origin: airbnb/lottie-android
case MaskModeAdd:
default:
path.computeBounds(tempMaskBoundsRect, false);
代码示例来源:origin: airbnb/lottie-android
@Override public void draw(Canvas canvas, Matrix parentMatrix, int parentAlpha) {
if (hidden) {
return;
}
L.beginSection("GradientFillContent#draw");
path.reset();
for (int i = 0; i < paths.size(); i++) {
path.addPath(paths.get(i).getPath(), parentMatrix);
}
path.computeBounds(boundsRect, false);
Shader shader;
if (type == GradientType.Linear) {
shader = getLinearGradient();
} else {
shader = getRadialGradient();
}
shaderMatrix.set(parentMatrix);
shader.setLocalMatrix(shaderMatrix);
paint.setShader(shader);
if (colorFilterAnimation != null) {
paint.setColorFilter(colorFilterAnimation.getValue());
}
int alpha = (int) ((parentAlpha / 255f * opacityAnimation.getValue() / 100f) * 255);
paint.setAlpha(clamp(alpha, 0, 255));
canvas.drawPath(path, paint);
L.endSection("GradientFillContent#draw");
}
代码示例来源:origin: airbnb/lottie-android
private void drawCharacterAsGlyph(
FontCharacter character,
Matrix parentMatrix,
float fontScale,
DocumentData documentData,
Canvas canvas) {
List<ContentGroup> contentGroups = getContentsForCharacter(character);
for (int j = 0; j < contentGroups.size(); j++) {
Path path = contentGroups.get(j).getPath();
path.computeBounds(rectF, false);
matrix.set(parentMatrix);
matrix.preTranslate(0, (float) -documentData.baselineShift * Utils.dpScale());
matrix.preScale(fontScale, fontScale);
path.transform(matrix);
if (documentData.strokeOverFill) {
drawGlyph(path, fillPaint, canvas);
drawGlyph(path, strokePaint, canvas);
} else {
drawGlyph(path, strokePaint, canvas);
drawGlyph(path, fillPaint, canvas);
}
}
}
代码示例来源:origin: tarek360/RichPath
public static boolean isTouched(Path path, float x, float y) {
Region region = new Region();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
region.setPath(path,
new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom));
int offset = 10;
return region.contains((int) x, (int) y)
|| region.contains((int) x + offset, (int) y + offset)
|| region.contains((int) x + offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y + offset);
}
代码示例来源:origin: facebook/litho
@GetExtraAccessibilityNodeAt
static int getExtraAccessibilityNodeAt(
int x,
int y,
@Prop(resType = ResType.STRING) CharSequence text,
@FromBoundsDefined Layout textLayout,
@FromBoundsDefined ClickableSpan[] clickableSpans) {
final Spanned spanned = (Spanned) text;
for (int i = 0; i < clickableSpans.length; i++) {
final ClickableSpan span = clickableSpans[i];
final int start = spanned.getSpanStart(span);
final int end = spanned.getSpanEnd(span);
textLayout.getSelectionPath(start, end, sTempPath);
sTempPath.computeBounds(sTempRectF, /* unused */true);
if (sTempRectF.contains(x, y)) {
return i;
}
}
return INVALID_ID;
}
}
内容来源于网络,如有侵权,请联系作者删除!