java类android.graphics.PathMeasure的实例源码

SearchView.java 文件源码 项目:Learn 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 初始化 Path
 */
private void initPath() {
    mSearchPath = new Path();
    mCirclePath = new Path();
    mMeasure = new PathMeasure();

    RectF oval1 = new RectF(-50, -50, 50, 50);
    mSearchPath.addArc(oval1, 45, 359.9f); // 放大镜的圆框

    RectF oval2 = new RectF(-100, -100, 100, 100);
    mCirclePath.addArc(oval2, 45, 359.9f); // 搜索的圆圈

    float[] pos = new float[2];
    mMeasure.setPath(mCirclePath, false);
    mMeasure.getPosTan(0, pos, null); // 放大镜手柄的末端

    mSearchPath.lineTo(pos[0], pos[1]); // 放大镜的手柄
}
PathKeyframeAnimation.java 文件源码 项目:lottie-android 阅读 24 收藏 0 点赞 0 评论 0
@Override public PointF getValue(Keyframe<PointF> keyframe, float keyframeProgress) {
  PathKeyframe pathKeyframe = (PathKeyframe) keyframe;
  Path path = pathKeyframe.getPath();
  if (path == null) {
    return keyframe.startValue;
  }

  if (pathMeasureKeyframe != pathKeyframe) {
    pathMeasure = new PathMeasure(path, false);
    pathMeasureKeyframe = pathKeyframe;
  }

  pathMeasure.getPosTan(keyframeProgress * pathMeasure.getLength(), pos, null);
  point.set(pos[0], pos[1]);
  return point;
}
PathInterpolatorDonut.java 文件源码 项目:Android-SpinKit 阅读 35 收藏 0 点赞 0 评论 0
public PathInterpolatorDonut(Path path) {
    final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);

    final float pathLength = pathMeasure.getLength();
    final int numPoints = (int) (pathLength / PRECISION) + 1;

    mX = new float[numPoints];
    mY = new float[numPoints];

    final float[] position = new float[2];
    for (int i = 0; i < numPoints; ++i) {
        final float distance = (i * pathLength) / (numPoints - 1);
        pathMeasure.getPosTan(distance, position, null /* tangent */);

        mX[i] = position[0];
        mY[i] = position[1];
    }
}
PathInterpolatorDonut.java 文件源码 项目:BaseLibrary 阅读 36 收藏 0 点赞 0 评论 0
public PathInterpolatorDonut(Path path) {
    final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);

    final float pathLength = pathMeasure.getLength();
    final int numPoints = (int) (pathLength / PRECISION) + 1;

    mX = new float[numPoints];
    mY = new float[numPoints];

    final float[] position = new float[2];
    for (int i = 0; i < numPoints; ++i) {
        final float distance = (i * pathLength) / (numPoints - 1);
        pathMeasure.getPosTan(distance, position, null /* tangent */);

        mX[i] = position[0];
        mY[i] = position[1];
    }
}
PathInterpolatorDonut.java 文件源码 项目:ShoppingApp 阅读 29 收藏 0 点赞 0 评论 0
public PathInterpolatorDonut(Path path) {
    final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);

    final float pathLength = pathMeasure.getLength();
    final int numPoints = (int) (pathLength / PRECISION) + 1;

    mX = new float[numPoints];
    mY = new float[numPoints];

    final float[] position = new float[2];
    for (int i = 0; i < numPoints; ++i) {
        final float distance = (i * pathLength) / (numPoints - 1);
        pathMeasure.getPosTan(distance, position, null /* tangent */);

        mX[i] = position[0];
        mY[i] = position[1];
    }
}
FreshDownloadView.java 文件源码 项目:FreshDownloadView 阅读 24 收藏 0 点赞 0 评论 0
public FreshDownloadView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    circular_edge = getResources().getDimension(R.dimen.edge);

    bounds = new Rect();
    mTempBounds = new RectF();
    publicPaint = new Paint();
    path1 = new Path();
    path2 = new Path();
    path3 = new Path();
    pathMeasure1 = new PathMeasure();
    pathMeasure2 = new PathMeasure();
    pathMeasure3 = new PathMeasure();
    textBounds = new Rect();

    parseAttrs(context.obtainStyledAttributes(attrs, R.styleable.FreshDownloadView));
    initPaint();
}
LoadingButton.java 文件源码 项目:DxLoadingButton 阅读 21 收藏 0 点赞 0 评论 0
private void createSuccessPath(){

        if(mSuccessPath != null){
            mSuccessPath.reset();
        }else{
            mSuccessPath = new Path();
        }

        float mLineWith = 2*mDensity;

        float left = width/2 - mRadius + mRadius/3 + mLineWith;
        float top = mPadding + mRadius/2 + mLineWith;
        float right = width/2 + mRadius - mLineWith - mRadius/3;
        float bottom = (mLineWith + mRadius) * 1.5f + mPadding/2;
        float xPoint = width/2 - mRadius/6;

        mSuccessPath = new Path();
        mSuccessPath.moveTo(left, mPadding+mRadius + mLineWith);
        mSuccessPath.lineTo(xPoint,bottom);
        mSuccessPath.lineTo(right,top);

        PathMeasure measure = new PathMeasure(mSuccessPath, false);
        mSuccessPathLength = measure.getLength();
        mSuccessPathIntervals = new float[]{mSuccessPathLength, mSuccessPathLength};
    }
LoadingButton.java 文件源码 项目:DxLoadingButton 阅读 31 收藏 0 点赞 0 评论 0
private void createFailedPath(){

        if(mFailedPath != null){
            mFailedPath.reset();
            mFailedPath2.reset();
        }else{
            mFailedPath = new Path();
            mFailedPath2 = new Path();
        }

        float left = width/2 - mRadius + mRadius/2;
        float top = mRadius/2 + mPadding;

        mFailedPath.moveTo(left,top);
        mFailedPath.lineTo(left+mRadius,top+mRadius);

        mFailedPath2.moveTo(width/2 + mRadius/2,top);
        mFailedPath2.lineTo(width/2 - mRadius + mRadius/2,top+mRadius);

        PathMeasure measure = new PathMeasure(mFailedPath, false);
        mFailedPathLength = measure.getLength();
        mFailedPathIntervals = new float[]{mFailedPathLength, mFailedPathLength};

        PathEffect PathEffect = new DashPathEffect(mFailedPathIntervals, mFailedPathLength);
        mPathEffectPaint2.setPathEffect(PathEffect);
    }
FllowerAnimation.java 文件源码 项目:AndroidStudyDemo 阅读 23 收藏 0 点赞 0 评论 0
private void init(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    width = wm.getDefaultDisplay().getWidth();
    height = (int) (wm.getDefaultDisplay().getHeight() * 3 / 2f);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStrokeWidth(2);
    mPaint.setColor(Color.BLUE);
    mPaint.setStyle(Paint.Style.STROKE);

    pathMeasure = new PathMeasure();

    builderFollower(fllowerCount, fllowers1);
    builderFollower(fllowerCount, fllowers2);
    builderFollower(fllowerCount, fllowers3);
}
NewCreditSesameView.java 文件源码 项目:CreditSesameRingView 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 绘制外层圆环进度和小圆点
 */
private void drawRingProgress(Canvas canvas) {

  Path path = new Path();
  path.addArc(mMiddleProgressRect, mStartAngle, mCurrentAngle);
  PathMeasure pathMeasure = new PathMeasure(path, false);
  pathMeasure.getPosTan(pathMeasure.getLength() * 1, pos, tan);
  matrix.reset();
  matrix.postTranslate(pos[0] - bitmap.getWidth() / 2, pos[1] - bitmap.getHeight() / 2);
  canvas.drawPath(path, mArcProgressPaint);
  //起始角度不为0时候才进行绘制小圆点
  if (mCurrentAngle == 0) {
    return;
  }
  canvas.drawBitmap(bitmap, matrix, mBitmapPaint);
  mBitmapPaint.setColor(Color.WHITE);
  canvas.drawCircle(pos[0], pos[1], 8, mBitmapPaint);
}


问题


面经


文章

微信
公众号

扫码关注公众号