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

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

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

Path.quadTo介绍

暂无

代码示例

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

@Override
  public void onAnimationUpdate(ValueAnimator valueAnimator) {
    float h = (Float) valueAnimator.getAnimatedValue();
    mWavePath.moveTo(0, 0);
    mWavePath.quadTo(0.25f * mWidth, 0, 0.333f * mWidth, h * 0.5f);
    mWavePath.quadTo(mWidth * 0.5f, h * 1.4f, 0.666f * mWidth, h * 0.5f);
    mWavePath.quadTo(0.75f * mWidth, 0, mWidth, 0);
    final View thisView = WaveView.this;
    thisView.postInvalidate();
  }
});

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

protected void drawWave(Canvas canvas, int width) {
  //重置画笔
  mPath.reset();
  //绘制贝塞尔曲线
  mPath.lineTo(0, mWaveTop);
  mPath.quadTo(mWaveOffsetX >= 0 ? (mWaveOffsetX) : width / 2, mWaveTop + mWaveHeight, width, mWaveTop);
  mPath.lineTo(width, 0);
  mPaint.setColor(mPrimaryColor);
  canvas.drawPath(mPath, mPaint);
}

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

private void drawBollTail(Canvas canvas, int viewWidth, float fraction) {
  if (mShowBollTail) {
    final float bottom = mHeadHeight + mWaveHeight;
    final float startY = mBollY + mBollRadius * fraction / 2;
    final float startX = viewWidth / 2 + (float) Math.sqrt(mBollRadius * mBollRadius * (1 - fraction * fraction / 4));
    final float bezier1x = (viewWidth / 2 + (mBollRadius * 3 / 4) * (1 - fraction));
    final float bezier2x = bezier1x + mBollRadius;
    mPath.reset();
    mPath.moveTo(startX, startY);
    mPath.quadTo(bezier1x, bottom, bezier2x, bottom);
    mPath.lineTo(viewWidth - bezier2x, bottom);
    mPath.quadTo(viewWidth - bezier1x, bottom, viewWidth - startX, startY);
    canvas.drawPath(mPath, mFrontPaint);
  }
}

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

private void drawSpringUp(Canvas canvas, int viewWidth) {
  if (mSpringRatio > 0) {
    float leftX = (viewWidth / 2 - 4 * mBollRadius + mSpringRatio * 3 * mBollRadius);
    if (mSpringRatio < 0.9) {
      mPath.reset();
      mPath.moveTo(leftX, mBollY);
      mPath.quadTo(viewWidth / 2, mBollY - mBollRadius * mSpringRatio * 2,
          viewWidth - leftX, mBollY);
      canvas.drawPath(mPath, mFrontPaint);
    } else {
      canvas.drawCircle(viewWidth / 2, mBollY, mBollRadius, mFrontPaint);
    }
  }
}

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

@NonNull
private Path generateBoxBodyPath(BoxBody body) {
  mPath.reset();
  mPath.moveTo(body.boxLeft, body.boxCenterBottom);
  mPath.lineTo(body.boxCenterX, body.boxBottom);
  mPath.lineTo(body.boxRight, body.boxCenterBottom);
  mPath.quadTo(body.boxRight + body.boxSideLength / 2 * mReboundPercent, body.boxCenterY, body.boxRight, body.boxCenterTop);
  mPath.lineTo(body.boxCenterX, body.boxTop);
  mPath.lineTo(body.boxLeft, body.boxCenterTop);
  mPath.quadTo(body.boxLeft - body.boxSideLength / 2 * mReboundPercent, body.boxCenterY, body.boxLeft, body.boxCenterBottom);
  mPath.close();
  return mPath;
}
//</editor-fold>

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

private static Path createQuad(float controlX, float controlY) {
  final Path path = new Path();
  path.moveTo(0.0f, 0.0f);
  path.quadTo(controlX, controlY, 1.0f, 1.0f);
  return path;
}

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

private void drawWave(Canvas canvas, int viewWidth, int viewHeight) {
  float baseHeight = Math.min(mHeadHeight, viewHeight);
  if (mWaveHeight != 0) {
    mPath.reset();
    mPath.lineTo(viewWidth, 0);
    mPath.lineTo(viewWidth, baseHeight);
    mPath.quadTo(viewWidth / 2, baseHeight + mWaveHeight * 2, 0, baseHeight);
    mPath.close();
    canvas.drawPath(mPath, mBackPaint);
  } else {
    canvas.drawRect(0, 0, viewWidth, baseHeight, mBackPaint);
  }
}

代码示例来源:origin: ankidroid/Anki-Android

private void drawAlong(float x, float y) {
  float dx = Math.abs(x - mX);
  float dy = Math.abs(y - mY);
  if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
    mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
    mX = x;
    mY = y;
  }
}

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

@Override
protected void dispatchDraw(Canvas canvas) {
  if (mShowBezierWave) {
    //重置画笔
    mBezierPath.reset();
    mBezierPath.lineTo(0, mHeadHeight);
    //绘制贝塞尔曲线
    final View thisView = this;
    mBezierPath.quadTo(thisView.getMeasuredWidth() / 2, mHeadHeight + mWaveHeight * 1.9f, thisView.getMeasuredWidth(), mHeadHeight);
    mBezierPath.lineTo(thisView.getMeasuredWidth(), 0);
    canvas.drawPath(mBezierPath, mBezierPaint);
  }
  super.dispatchDraw(canvas);
}

代码示例来源:origin: UFreedom/FloatingView

@Override
public FloatingPath getFloatingPath() {
  if (mPath == null){
    mPath = new Path();
    mPath.moveTo(0, 0);
    mPath.quadTo(-100, -200, 0, -300);
    mPath.quadTo(200, -400, 0, -500);
  }
  return FloatingPath.create(mPath, false);
}

代码示例来源:origin: hackware1993/MagicIndicator

/**
 * 绘制贝塞尔曲线
 *
 * @param canvas
 */
private void drawBezierCurve(Canvas canvas) {
  mPath.reset();
  float y = getHeight() - mYOffset - mMaxCircleRadius;
  mPath.moveTo(mRightCircleX, y);
  mPath.lineTo(mRightCircleX, y - mRightCircleRadius);
  mPath.quadTo(mRightCircleX + (mLeftCircleX - mRightCircleX) / 2.0f, y, mLeftCircleX, y - mLeftCircleRadius);
  mPath.lineTo(mLeftCircleX, y + mLeftCircleRadius);
  mPath.quadTo(mRightCircleX + (mLeftCircleX - mRightCircleX) / 2.0f, y, mRightCircleX, y + mRightCircleRadius);
  mPath.close();  // 闭合
  canvas.drawPath(mPath, mPaint);
}

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

private Path createMoonPath(float moonCenterX, float moonCenterY) {
  RectF moonRectF = new RectF(moonCenterX - mSun$MoonRadius, moonCenterY - mSun$MoonRadius,
      moonCenterX + mSun$MoonRadius, moonCenterY + mSun$MoonRadius);
  Path path = new Path();
  path.addArc(moonRectF, -90, 180);
  path.quadTo(moonCenterX + mSun$MoonRadius / 2.0f, moonCenterY, moonCenterX, moonCenterY - mSun$MoonRadius);
  return path;
}

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

private Path createRightEyeCircle(RectF arcBounds, float offsetY) {
  Path path = new Path();
  //the center of the right eye
  float rightEyeCenterX = arcBounds.centerX() + mEyeInterval / 2.0f + mEyeCircleRadius;
  float rightEyeCenterY = arcBounds.centerY() + offsetY;
  //the bounds of left eye
  RectF leftEyeBounds = new RectF(rightEyeCenterX - mEyeCircleRadius, rightEyeCenterY - mEyeCircleRadius,
      rightEyeCenterX + mEyeCircleRadius, rightEyeCenterY + mEyeCircleRadius);
  path.addArc(leftEyeBounds, 180, -(DEGREE_180 + 15));
  //the above radian of of the eye
  path.quadTo(leftEyeBounds.right - mAboveRadianEyeOffsetX, leftEyeBounds.top + mEyeCircleRadius * 0.2f,
      leftEyeBounds.right - mAboveRadianEyeOffsetX / 4.0f, leftEyeBounds.top - mEyeCircleRadius * 0.15f);
  return path;
}

代码示例来源:origin: UFreedom/FloatingView

@Override
public FloatingPath getFloatingPath() {
  Path path = new Path();
  path.rLineTo(-100,0);
  path.quadTo(0,-200,100,0);
  path.quadTo(0,200,-100,0);
  return FloatingPath.create(path, false);
}

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

private Path createLeftEyeCircle(RectF arcBounds, float offsetY) {
  Path path = new Path();
  //the center of the left eye
  float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
  float leftEyeCenterY = arcBounds.centerY() + offsetY;
  //the bounds of left eye
  RectF leftEyeBounds = new RectF(leftEyeCenterX - mEyeCircleRadius, leftEyeCenterY - mEyeCircleRadius,
      leftEyeCenterX + mEyeCircleRadius, leftEyeCenterY + mEyeCircleRadius);
  path.addArc(leftEyeBounds, 0, DEGREE_180 + 15);
  //the above radian of of the eye
  path.quadTo(leftEyeBounds.left + mAboveRadianEyeOffsetX, leftEyeBounds.top + mEyeCircleRadius * 0.2f,
      leftEyeBounds.left + mAboveRadianEyeOffsetX / 4.0f, leftEyeBounds.top - mEyeCircleRadius * 0.15f);
  return path;
}

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

private void makeBezierPath() {
  mPath.reset();
  mPath.addCircle(topCircle.x, topCircle.y, topCircle.radius, Path.Direction.CCW);
  if (bottomCircle.y > topCircle.y + DensityUtil.dp2px(1)) {
    mPath.addCircle(bottomCircle.x, bottomCircle.y, bottomCircle.radius, Path.Direction.CCW);
    //获取两圆的两个切线形成的四个切点
    double angle = getAngle();
    float top_x1 = (float) (topCircle.x - topCircle.radius * Math.cos(angle));
    float top_y1 = (float) (topCircle.y + topCircle.radius * Math.sin(angle));
    float top_x2 = (float) (topCircle.x + topCircle.radius * Math.cos(angle));
    float top_y2 = top_y1;
    float bottom_x1 = (float) (bottomCircle.x - bottomCircle.radius * Math.cos(angle));
    float bottom_y1 = (float) (bottomCircle.y + bottomCircle.radius * Math.sin(angle));
    float bottom_x2 = (float) (bottomCircle.x + bottomCircle.radius * Math.cos(angle));
    float bottom_y2 = bottom_y1;
    mPath.moveTo(topCircle.x, topCircle.y);
    mPath.lineTo(top_x1, top_y1);
    mPath.quadTo((bottomCircle.x - bottomCircle.radius),
        (bottomCircle.y + topCircle.y) / 2,
        bottom_x1,bottom_y1);
    mPath.lineTo(bottom_x2, bottom_y2);
    mPath.quadTo((bottomCircle.x + bottomCircle.radius),
        (bottomCircle.y + top_y2) / 2,
        top_x2,top_y2);
  }
  mPath.close();
}

代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout

@Override
protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  path.reset();
  paint.setColor(color);
  path.lineTo(0, headHeight);
  path.quadTo(getMeasuredWidth() / 2, headHeight + waveHeight, getMeasuredWidth(), headHeight);
  path.lineTo(getMeasuredWidth(), 0);
  canvas.drawPath(path, paint);
}

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

@Test
public void testReset() throws Exception {
 Path path = new Path();
 path.moveTo(0, 3);
 path.lineTo(2, 3);
 path.quadTo(2, 3, 4, 5);
 path.reset();
 ShadowPath shadowPath = shadowOf(path);
 List<ShadowPath.Point> points = shadowPath.getPoints();
 assertEquals(0, points.size());
}

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

@Test
 public void test_copyConstructor() throws Exception {
  Path path = new Path();
  path.moveTo(0, 3);
  path.lineTo(2, 3);
  path.quadTo(2, 3, 4, 5);

  Path copiedPath = new Path(path);
  assertEquals(shadowOf(path).getPoints(), shadowOf(copiedPath).getPoints());
 }
}

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

@Test
public void quadTo() {
 Path path = new Path();
 assertThat(path.isEmpty()).isTrue();
 path.quadTo(20.0f, 20.0f, 40.0f, 40.0f);
 assertThat(path.isEmpty()).isFalse();
}

相关文章