public void transform(Matrix matrix, Path dst) { path.transform(matrix, dst); } }
public static void setPathScaleX(Path path, float scale, float px, float py) { Matrix matrix = new Matrix(); matrix.setScale(scale, 1, px, py); path.transform(matrix); }
public static void setPathScaleY(Path path, float scale, float px, float py) { Matrix matrix = new Matrix(); matrix.setScale(1, scale, px, py); path.transform(matrix); }
public static void setPathTranslationX(Path path, float translationX) { Matrix matrix = new Matrix(); matrix.postTranslate(translationX, 0); path.transform(matrix); }
@Override @NonNull public Path getPath(float startX, float startY, float endX, float endY) { double dx = endX - startX; double dy = endY - startY; float length = (float) Math.hypot(dx, dy); double angle = Math.atan2(dy, dx); mTempMatrix.setScale(length, length); mTempMatrix.postRotate((float) Math.toDegrees(angle)); mTempMatrix.postTranslate(startX, startY); Path path = new Path(); mPatternPath.transform(mTempMatrix, path); return path; }
@Override protected void onDraw(@NonNull Canvas canvas, int width, int height, @NonNull Paint paint) { // Drawing the transformed path makes rendering much less blurry than using canvas transform // directly. See https://stackoverflow.com/a/16091390 . RectF bound = mUseIntrinsicPadding ? RECT_PADDED_BOUND : RECT_PROGRESS_BOUND; mMatrix.setScale(width / bound.width(), height / bound.height()); mMatrix.preTranslate(-bound.left, -bound.top); PATH_PROGRESS.transform(mMatrix, mPath); canvas.drawPath(mPath, paint); } }
public static void setPathTranslationY(Path path, float translationY) { Matrix matrix = new Matrix(); matrix.setTranslate(0, translationY); path.transform(matrix); }
public static void setPathRotation(Path path, float rotation, float px, float py) { Matrix matrix = new Matrix(); matrix.setRotate(rotation, px, py); path.transform(matrix); }
public static List<Path> transformScale(float ratioWidth, float ratioHeight, List<Path> originPaths, List<String> orginSvgs) { Matrix matrix = new Matrix(); matrix.setScale(ratioWidth, ratioHeight); List<Path> paths = new ArrayList<>(); if (Build.VERSION.SDK_INT > 16) { for (Path path : originPaths) { Path nPath = new Path(); path.transform(matrix, nPath); paths.add(nPath); } } else { for (String svgPath : orginSvgs) { Path path = new Path(); PathDataNode[] nodes = createNodesFromPathData(svgPath); transformScaleNodes(ratioWidth, ratioHeight, nodes); PathDataNode.nodesToPath(nodes, path); paths.add(path); } } return paths; }
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); }
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); }
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); }
for (int j = pathList.size() - 1; j >= 0; j--) { Path path = pathList.get(j).getPath(); path.transform(((ContentGroup) content).getTransformationMatrix()); this.remainderPath.addPath(path); for (int j = 0; j < pathList.size(); j++) { Path path = pathList.get(j).getPath(); path.transform(((ContentGroup) lastContent).getTransformationMatrix()); this.firstPath.addPath(path);
void mapToMatrix(Matrix matrix) { matrices.add(matrix); transform(matrix); originalPath.transform(matrix); mapPoints(matrix); updateOriginalDimens(); }
Path maskPath = maskAnimation.getValue(); path.set(maskPath); path.transform(matrix);
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); } } }
@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(); }
Path maskPath = maskAnimation.getValue(); path.set(maskPath); path.transform(matrix); BaseKeyframeAnimation<Integer, Integer> opacityAnimation = this.mask.getOpacityAnimations().get(i);