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

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

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

Path.<init>介绍

暂无

代码示例

代码示例来源:origin: square/picasso

private static Path getTrianglePath(int x1, int y1, int width) {
  final Path path = new Path();
  path.moveTo(x1, y1);
  path.lineTo(x1 + width, y1);
  path.lineTo(x1, y1 + width);

  return path;
 }
}

代码示例来源:origin: zhihu/Matisse

private void init(Context context) {
  float density = context.getResources().getDisplayMetrics().density;
  mRadius = 2.0f * density;
  mRoundedRectPath = new Path();
  mRectF = new RectF();
}

代码示例来源: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: TeamNewPipe/NewPipe

public void setMarquee(boolean marquee) {
  if (marquee == (mMarqueeLine != null)) {
    return;
  }
  mMarqueeLine = marquee ? new Path() : null;
  mMarqueeHandler = marquee ? new Handler(Looper.getMainLooper()) : null;
  mMarqueeSize = 0;
  mMarqueeNext = 0;
}

代码示例来源:origin: square/leakcanary

SquigglySpan(Resources resources) {
 squigglyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
 squigglyPaint.setStyle(Paint.Style.STROKE);
 squigglyPaint.setColor(resources.getColor(R.color.leak_canary_leak));
 float strokeWidth =
   resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_stroke_width);
 squigglyPaint.setStrokeWidth(strokeWidth);
 halfStrokeWidth = strokeWidth / 2;
 amplitude = resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_amplitude);
 periodDegrees =
   resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_period_degrees);
 path = new Path();
 float waveHeight = 2 * amplitude + strokeWidth;
 halfWaveHeight = waveHeight / 2;
 referenceColor = resources.getColor(R.color.leak_canary_reference);
}

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

private void init() {
    // A new paint with the style as stroke.
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(textColor);
    mPaint.setStrokeWidth(5.0f);
    mPaint.setStyle(Paint.Style.STROKE);
    mPath = new Path();
  }
}

代码示例来源:origin: rey5137/material

public HeaderDrawable(Context context){
  mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setColor(ThemeUtil.colorPrimary(context, 0));
  mPaint.setStyle(Paint.Style.FILL);
  mPath = new Path();
}

代码示例来源: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: naman14/Timber

/**
 * Initialize the {@code Path} objects with the appropriate values.
 */
private void initPaths() {
  mCirclePath = new Path();
  mCirclePath.addArc(mCircleRectF, mStartAngle, mTotalCircleDegrees);
  mCircleProgressPath = new Path();
  mCircleProgressPath.addArc(mCircleRectF, mStartAngle, mProgressDegrees);
}

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

public BezierCircleHeader(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
  mSpinnerStyle = SpinnerStyle.Scale;
  final View thisView = this;
  thisView.setMinimumHeight(DensityUtil.dp2px(100));
  mBackPaint = new Paint();
  mBackPaint.setColor(0xff11bbff);
  mBackPaint.setAntiAlias(true);
  mFrontPaint = new Paint();
  mFrontPaint.setColor(0xffffffff);
  mFrontPaint.setAntiAlias(true);
  mOuterPaint = new Paint();
  mOuterPaint.setAntiAlias(true);
  mOuterPaint.setColor(0xffffffff);
  mOuterPaint.setStyle(Paint.Style.STROKE);
  mOuterPaint.setStrokeWidth(DensityUtil.dp2px(2f));
  mPath = new Path();
}

代码示例来源: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: scwang90/SmartRefreshLayout

/**
 * @param pathData The string representing a path, the same as "d" string in svg file.
 * @return the generated Path object.
 */
public static Path createPathFromPathData(String pathData) {
  Path path = new Path();
  PathDataNode[] nodes = createNodesFromPathData(pathData);
  if (nodes != null) {
    try {
      PathDataNode.nodesToPath(nodes, path);
    } catch (RuntimeException e) {
      throw new RuntimeException("Error in parsing " + pathData, e);
    }
    return path;
  }
  return null;
}

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

@Implementation
protected void drawPath(Path path, Paint paint) {
 pathPaintEvents.add(new PathPaintHistoryEvent(new Path(path), new Paint(paint)));
 separateLines();
 ShadowPath shadowPath = Shadow.extract(path);
 appendDescription("Path " + shadowPath.getPoints().toString());
}

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

@Implementation
protected static Path createPathFromPathData(String pathData) {
 Path path = new Path();
 PathDataNode[] nodes = createNodesFromPathData(pathData);
 if (nodes != null) {
  PathDataNode.nodesToPath(nodes, path);
  return path;
 }
 return null;
}

代码示例来源: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 resetCanvasHistory_shouldClearTheHistoryAndDescription() throws Exception {
 Canvas canvas = new Canvas();
 canvas.drawPath(new Path(), new Paint());
 canvas.drawText("hi", 1, 2, new Paint());
 ShadowCanvas shadow = shadowOf(canvas);
 shadow.resetCanvasHistory();
 assertThat(shadow.getPathPaintHistoryCount()).isEqualTo(0);
 assertThat(shadow.getTextHistoryCount()).isEqualTo(0);
 assertEquals("", shadow.getDescription());
}

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

@Test
public void testLineTo() throws Exception {
 Path path = new Path();
 path.lineTo(2, 3);
 path.lineTo(3, 4);
 List<ShadowPath.Point> lineToPoints = shadowOf(path).getPoints();
 assertEquals(2, lineToPoints.size());
 assertEquals(new ShadowPath.Point(2, 3, LINE_TO), lineToPoints.get(0));
 assertEquals(new ShadowPath.Point(3, 4, LINE_TO), lineToPoints.get(1));
}

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

@Test
public void testMoveTo() throws Exception {
 Path path = new Path();
 path.moveTo(2, 3);
 path.moveTo(3, 4);
 List<ShadowPath.Point> moveToPoints = shadowOf(path).getPoints();
 assertEquals(2, moveToPoints.size());
 assertEquals(new ShadowPath.Point(2, 3, MOVE_TO), moveToPoints.get(0));
 assertEquals(new ShadowPath.Point(3, 4, MOVE_TO), moveToPoints.get(1));
}

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

@Test
  public void setConvexPath_doesNothing() {
    final Outline outline = new Outline();
    outline.setConvexPath(new Path());
  }
}

相关文章