android.graphics.Path.cubicTo()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(300)

本文整理了Java中android.graphics.Path.cubicTo()方法的一些代码示例,展示了Path.cubicTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.cubicTo()方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:cubicTo

Path.cubicTo介绍

暂无

代码示例

代码示例来源:origin: ybq/Android-SpinKit

private static Path createCubic(float controlX1, float controlY1,
                  float controlX2, float controlY2) {
    final Path path = new Path();
    path.moveTo(0.0f, 0.0f);
    path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0f, 1.0f);
    return path;
  }
}

代码示例来源:origin: dinuscxj/LoadingDrawable

private Path createChildPath() {
  float bezierOffset = mChildOvalRadius * OVAL_BEZIER_FACTOR;
  Path path = new Path();
  path.moveTo(mChildPosition[0], mChildPosition[1] - mChildOvalRadius);
  //left_top arc
  path.cubicTo(mChildPosition[0] - bezierOffset - mChildLeftXOffset, mChildPosition[1] - mChildOvalRadius,
      mChildPosition[0] - mChildOvalRadius - mChildLeftXOffset, mChildPosition[1] - bezierOffset + mChildLeftYOffset,
      mChildPosition[0] - mChildOvalRadius - mChildLeftXOffset, mChildPosition[1]);
  //left_bottom arc
  path.cubicTo(mChildPosition[0] - mChildOvalRadius - mChildLeftXOffset, mChildPosition[1] + bezierOffset - mChildLeftYOffset,
      mChildPosition[0] - bezierOffset - mChildLeftXOffset, mChildPosition[1] + mChildOvalRadius,
      mChildPosition[0], mChildPosition[1] + mChildOvalRadius);
  //right_bottom arc
  path.cubicTo(mChildPosition[0] + bezierOffset + mChildRightXOffset, mChildPosition[1] + mChildOvalRadius,
      mChildPosition[0] + mChildOvalRadius + mChildRightXOffset, mChildPosition[1] + bezierOffset - mChildRightYOffset,
      mChildPosition[0] + mChildOvalRadius + mChildRightXOffset, mChildPosition[1]);
  //right_top arc
  path.cubicTo(mChildPosition[0] + mChildOvalRadius + mChildRightXOffset, mChildPosition[1] - bezierOffset + mChildRightYOffset,
      mChildPosition[0] + bezierOffset + mChildRightXOffset, mChildPosition[1] - mChildOvalRadius,
      mChildPosition[0], mChildPosition[1] - mChildOvalRadius);
  return path;
}

代码示例来源:origin: scwang90/SmartRefreshLayout

public void beginPhase(float move1) {
  onPreDragWave();
  //円を描画し始める前の引っ張ったら膨れる波の部分の描画
  mWavePath.moveTo(0, 0);
  //左半分の描画
  mWavePath.cubicTo(mWidth * BEGIN_PHASE_POINTS[0][0], BEGIN_PHASE_POINTS[0][1],
      mWidth * BEGIN_PHASE_POINTS[1][0], mWidth * (BEGIN_PHASE_POINTS[1][1] + move1),
      mWidth * BEGIN_PHASE_POINTS[2][0], mWidth * (BEGIN_PHASE_POINTS[2][1] + move1));
  mWavePath.cubicTo(mWidth * BEGIN_PHASE_POINTS[3][0],
      mWidth * (BEGIN_PHASE_POINTS[3][1] + move1), mWidth * BEGIN_PHASE_POINTS[4][0],
      mWidth * (BEGIN_PHASE_POINTS[4][1] + move1), mWidth * BEGIN_PHASE_POINTS[5][0],
      mWidth * (BEGIN_PHASE_POINTS[5][1] + move1));
  //右半分の描画
  mWavePath.cubicTo(mWidth - mWidth * BEGIN_PHASE_POINTS[4][0],
      mWidth * (BEGIN_PHASE_POINTS[4][1] + move1), mWidth - mWidth * BEGIN_PHASE_POINTS[3][0],
      mWidth * (BEGIN_PHASE_POINTS[3][1] + move1), mWidth - mWidth * BEGIN_PHASE_POINTS[2][0],
      mWidth * (BEGIN_PHASE_POINTS[2][1] + move1));
  mWavePath.cubicTo(mWidth - mWidth * BEGIN_PHASE_POINTS[1][0],
      mWidth * (BEGIN_PHASE_POINTS[1][1] + move1), mWidth - mWidth * BEGIN_PHASE_POINTS[0][0],
      BEGIN_PHASE_POINTS[0][1], mWidth, 0);
  final View thisView = this;
  if (Build.VERSION.SDK_INT >= 16) {
    thisView.postInvalidateOnAnimation();
  } else {
    thisView.invalidate();
  }
}

代码示例来源:origin: airbnb/lottie-android

public static Path createPath(PointF startPoint, PointF endPoint, PointF cp1, PointF cp2) {
 Path path = new Path();
 path.moveTo(startPoint.x, startPoint.y);
 if (cp1 != null  && cp2 != null && (cp1.length() != 0 || cp2.length() != 0)) {
  path.cubicTo(
    startPoint.x + cp1.x, startPoint.y + cp1.y,
    endPoint.x + cp2.x, endPoint.y + cp2.y,
    endPoint.x, endPoint.y);
 } else {
  path.lineTo(endPoint.x, endPoint.y);
 }
 return path;
}

代码示例来源:origin: airbnb/lottie-android

if (circleShape.isReversed()) {
 path.moveTo(0, -halfHeight);
 path.cubicTo(0 - cpW, -halfHeight, -halfWidth, 0 - cpH, -halfWidth, 0);
 path.cubicTo(-halfWidth, 0 + cpH, 0 - cpW, halfHeight, 0, halfHeight);
 path.cubicTo(0 + cpW, halfHeight, halfWidth, 0 + cpH, halfWidth, 0);
 path.cubicTo(halfWidth, 0 - cpH, 0 + cpW, -halfHeight, 0, -halfHeight);
} else {
 path.moveTo(0, -halfHeight);
 path.cubicTo(0 + cpW, -halfHeight, halfWidth, 0 - cpH, halfWidth, 0);
 path.cubicTo(halfWidth, 0 + cpH, 0 + cpW, halfHeight, 0, halfHeight);
 path.cubicTo(0 - cpW, halfHeight, -halfWidth, 0 + cpH, -halfWidth, 0);
 path.cubicTo(-halfWidth, 0 - cpH, 0 - cpW, -halfHeight, 0, -halfHeight);

代码示例来源:origin: scwang90/SmartRefreshLayout

mWavePath.moveTo(0, 0);
mWavePath.cubicTo(mWidth * APPEAR_PHASE_POINTS[0][0], mWidth * APPEAR_PHASE_POINTS[0][1],
    mWidth * Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]),
    mWidth * Math.max(BEGIN_PHASE_POINTS[1][1] + move1 - move2, APPEAR_PHASE_POINTS[1][1]),
    mWidth * Math.max(BEGIN_PHASE_POINTS[2][0] - move2, APPEAR_PHASE_POINTS[2][0]),
    mWidth * Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]));
mWavePath.cubicTo(
    mWidth * Math.max(BEGIN_PHASE_POINTS[3][0] - move2, APPEAR_PHASE_POINTS[3][0]),
    mWidth * Math.min(BEGIN_PHASE_POINTS[3][1] + move1 + move2, APPEAR_PHASE_POINTS[3][1]),
    mWidth * Math.min(BEGIN_PHASE_POINTS[0][1] + move1 + move2, APPEAR_PHASE_POINTS[5][1]));
mWavePath.cubicTo(
    mWidth - mWidth * Math.max(BEGIN_PHASE_POINTS[4][0] - move2, APPEAR_PHASE_POINTS[4][0]),
    mWidth * Math.min(BEGIN_PHASE_POINTS[4][1] + move1 + move2, APPEAR_PHASE_POINTS[4][1]),
    mWidth - mWidth * Math.max(BEGIN_PHASE_POINTS[2][0] - move2, APPEAR_PHASE_POINTS[2][0]),
    mWidth * Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]));
mWavePath.cubicTo(
    mWidth - mWidth * Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]),
    mWidth * Math.max(BEGIN_PHASE_POINTS[1][1] + move1 - move2, APPEAR_PHASE_POINTS[1][1]),

代码示例来源:origin: scwang90/SmartRefreshLayout

mMount3.reset();
mMount3.moveTo(0, 114 + offset3);
mMount3.cubicTo(30, 106 + offset3, 196, 97 + offset3, WIDTH, 104 + offset3);
mMount3.lineTo(WIDTH, height / mScaleY);
mMount3.lineTo(0, height / mScaleY);

代码示例来源:origin: scwang90/SmartRefreshLayout

mWavePath.moveTo(0, 0);
mWavePath.cubicTo(mWidth * EXPAND_PHASE_POINTS[0][0], mWidth * EXPAND_PHASE_POINTS[0][1],
    mWidth * Math.min(
        Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]) + move3,
        Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]) + move3,
        EXPAND_PHASE_POINTS[2][1]));
mWavePath.cubicTo(mWidth * Math.min(
    Math.max(BEGIN_PHASE_POINTS[3][0] - move2, APPEAR_PHASE_POINTS[3][0]) + move3,
    EXPAND_PHASE_POINTS[3][0]), mWidth * Math.min(
mWavePath.cubicTo(
    mWidth - mWidth * Math.max(BEGIN_PHASE_POINTS[4][0] - move2, EXPAND_PHASE_POINTS[4][0]),
    mWidth * Math.min(
        Math.max(BEGIN_PHASE_POINTS[2][1] + move1 - move2, APPEAR_PHASE_POINTS[2][1]) + move3,
        EXPAND_PHASE_POINTS[2][1]));
mWavePath.cubicTo(mWidth - mWidth * Math.min(
    Math.min(BEGIN_PHASE_POINTS[1][0] + move2, APPEAR_PHASE_POINTS[1][0]) + move3,
    EXPAND_PHASE_POINTS[1][0]), mWidth * Math.max(

代码示例来源:origin: naman14/Timber

@Override
protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  if (controlPoints == null) return;
  int length = controlPoints.length;
  int height = getMeasuredHeight();
  int width = getMeasuredWidth();
  float minDimen = height > width ? width : height;
  mPath.reset();
  mPath.moveTo(minDimen * controlPoints[0][0], minDimen * controlPoints[0][1]);
  for (int i = 1; i < length; i += 3) {
    mPath.cubicTo(minDimen * controlPoints[i][0], minDimen * controlPoints[i][1],
        minDimen * controlPoints[i + 1][0], minDimen * controlPoints[i + 1][1],
        minDimen * controlPoints[i + 2][0], minDimen * controlPoints[i + 2][1]);
  }
  canvas.drawPath(mPath, mPaint);
}

代码示例来源:origin: dinuscxj/LoadingDrawable

private Path createWaterPath(RectF waterRect, float progress) {
  Path path = new Path();
  path.moveTo(waterRect.left, waterRect.top);
  //Similar to the way draw the bottle's bottom sides
  float radius = (waterRect.width() - mStrokeWidth) / 2.0f;
  float centerY = waterRect.bottom - 0.86f * radius;
  float bottleBottomWidth = waterRect.width() / 2.0f;
  RectF bodyRect = new RectF(waterRect.left, centerY - radius, waterRect.right, centerY + radius);
  path.addArc(bodyRect, 187.5f, -67.5f);
  path.lineTo(waterRect.centerX() - bottleBottomWidth / 2.0f, waterRect.bottom);
  path.lineTo(waterRect.centerX() + bottleBottomWidth / 2.0f, waterRect.bottom);
  path.addArc(bodyRect, 60, -67.5f);
  //draw the water waves
  float cubicXChangeSize = waterRect.width() * 0.35f * progress;
  float cubicYChangeSize = waterRect.height() * 1.2f * progress;
  path.cubicTo(waterRect.left + waterRect.width() * 0.80f - cubicXChangeSize, waterRect.top - waterRect.height() * 1.2f + cubicYChangeSize,
      waterRect.left + waterRect.width() * 0.55f - cubicXChangeSize, waterRect.top - cubicYChangeSize,
      waterRect.left, waterRect.top - mStrokeWidth / 2.0f);
  path.lineTo(waterRect.left, waterRect.top);
  return path;
}

代码示例来源:origin: scwang90/SmartRefreshLayout

p.cubicTo((float) q1x,
    (float) q1y,
    (float) q2x,

代码示例来源:origin: robolectric/robolectric

double q2y = e2y - alpha * ep2y;
p.cubicTo((float) q1x, (float) q1y, (float) q2x, (float) q2y, (float) e2x, (float) e2y);
eta1 = eta2;
e1x = e2x;

代码示例来源:origin: dinuscxj/LoadingDrawable

float leftIncrementY3 = progressHeight * -1.0f;
path.cubicTo(balloonRect.left + balloonRect.width() * 0.25f + leftIncrementX1, balloonRect.centerY() - balloonRect.height() * 0.4f + leftIncrementY1,
    balloonRect.left - balloonRect.width() * 0.20f + leftIncrementX2, balloonRect.centerY() + balloonRect.height() * 1.15f + leftIncrementY2,
    balloonRect.left - balloonRect.width() * 0.4f + leftIncrementX3, balloonRect.bottom + leftIncrementY3);
float rightIncrementY3 = 0.0f;
path.cubicTo(balloonRect.left - balloonRect.width() * 0.38f + rightIncrementX1, balloonRect.centerY() - balloonRect.height() * 0.4f + rightIncrementY1,
    balloonRect.left + balloonRect.width() * 1.1f + rightIncrementX2, balloonRect.centerY() - balloonRect.height() * 0.15f + rightIncrementY2,
    balloonRect.left + balloonRect.width() * 0.5f + rightIncrementX3, balloonRect.bottom + rightIncrementY3);

代码示例来源:origin: dinuscxj/LoadingDrawable

path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f,
    bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius,
    bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f,
    bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f,
    bounds.centerX() + mWaitCircleRadius, bounds.centerY());
    bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 2, -2);
path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f,
    bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius,
    bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f,
    bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f,
    bounds.centerX() + mWaitCircleRadius, bounds.centerY());

代码示例来源:origin: airbnb/lottie-android

float cp2x = radius * roundedness * POLYGON_MAGIC_NUMBER * cp2Dx;
 float cp2y = radius * roundedness * POLYGON_MAGIC_NUMBER * cp2Dy;
 path.cubicTo(previousX - cp1x,previousY - cp1y, x + cp2x, y + cp2y, x, y);
} else {
 path.lineTo(x, y);

代码示例来源:origin: airbnb/lottie-android

public static void getPathFromData(ShapeData shapeData, Path outPath) {
 outPath.reset();
 PointF initialPoint = shapeData.getInitialPoint();
 outPath.moveTo(initialPoint.x, initialPoint.y);
 pathFromDataCurrentPoint.set(initialPoint.x, initialPoint.y);
 for (int i = 0; i < shapeData.getCurves().size(); i++) {
  CubicCurveData curveData = shapeData.getCurves().get(i);
  PointF cp1 = curveData.getControlPoint1();
  PointF cp2 = curveData.getControlPoint2();
  PointF vertex = curveData.getVertex();
  if (cp1.equals(pathFromDataCurrentPoint) && cp2.equals(vertex)) {
   // On some phones like Samsung phones, zero valued control points can cause artifacting.
   // https://github.com/airbnb/lottie-android/issues/275
   //
   // This does its best to add a tiny value to the vertex without affecting the final
   // animation as much as possible.
   // outPath.rMoveTo(0.01f, 0.01f);
   outPath.lineTo(vertex.x, vertex.y);
  } else {
   outPath.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, vertex.x, vertex.y);
  }
  pathFromDataCurrentPoint.set(vertex.x, vertex.y);
 }
 if (shapeData.isClosed()) {
  outPath.close();
 }
}

代码示例来源:origin: airbnb/lottie-android

path.cubicTo(previousX - cp1x,previousY - cp1y, x + cp2x, y + cp2y, x, y);

代码示例来源:origin: dinuscxj/LoadingDrawable

currentPathLength += mStageChildBackwardTopLeftLength;
path.cubicTo(centerX, centerY + mMotherOvalHalfHeight,
    centerX - mMotherOvalHalfWidth, centerY + mMotherOvalHalfHeight * 2.5f,
    centerX - mMotherOvalHalfWidth * 1.5f, centerY + mMotherOvalHalfHeight * 2.5f);
currentPathLength += mStageChildForwardBottomLeftLength;
path.cubicTo(
    centerX - mMotherOvalHalfWidth * 2.0f, centerY + mMotherOvalHalfHeight * 2.5f,
    centerX - mMotherOvalHalfWidth * 3.0f, centerY + mMotherOvalHalfHeight * 0.8f,

代码示例来源:origin: PhilJay/MPAndroidChart

+ (cur.getX() - prev.getX()) / 2.0f;
cubicPath.cubicTo(
    cpx, prev.getY() * phaseY,
    cpx, cur.getY() * phaseY,

代码示例来源:origin: PhilJay/MPAndroidChart

curDy = (next.getY() - prev.getY()) * intensity;
cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY,
    cur.getX() - curDx,
    (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY);

相关文章