android.graphics.Path#isEmpty ( )源码实例Demo

下面列出了android.graphics.Path#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: litho   文件: BorderColorDrawable.java
private static void drawBorder(
    Canvas canvas, RectF bounds, Path path, float[] radii, Paint paint) {
  float maxRadii = Math.min(bounds.width(), bounds.height()) / 2f;
  if (path == null) {
    // All radii are the same
    float radius = Math.min(maxRadii, radii[0]);
    canvas.drawRoundRect(bounds, radius, radius, paint);
  } else {
    if (path.isEmpty()) {
      path.addRoundRect(bounds, radii, Path.Direction.CW);
    }
    canvas.drawPath(path, paint);
  }
}
 
public OBPath StarWithScale(float scale,boolean shadow)
{
    Path starpath = new Path();
    boolean outer = true;
    PointF pt = new PointF();
    for (double ang = -(Math.PI);ang < Math.PI;ang += (2.0 * Math.PI / 10.0))
    {
        double cosang = Math.cos(ang);
        double sinang = Math.sin(ang);
        if (outer)
            pt.set((float) cosang, (float) sinang);
        else
            pt.set((float)cosang*0.5f, (float)sinang*0.5f);
        pt.x += 1.0;
        pt.y += 1.0;
        pt.x *= scale;
        pt.y *= scale;
        outer = !outer;
        if (starpath.isEmpty())
            starpath.moveTo(pt.x,pt.y);
        else
            starpath.lineTo(pt.x,pt.y);
    }
    starpath.close();
    Matrix m = new Matrix();
    m.postRotate(28.87f);
    starpath.transform(m);
    OBPath p = new OBPath(starpath);
    p.sizeToBoundingBoxIncludingStroke();
    float r = 1.0f,g = 216.0f/255.0f,b = 0.0f;
    p.setFillColor(Color.argb(255, (int) (r * 255), (int) (g * 255), (int) (b * 255)));
    p.setStrokeColor(Color.argb((int)(0.7*255),(int)(r*0.7*255),(int)(g*0.7*255),(int)(b*0.7*255)));
    p.setZPosition(200);
    return p;
}
 
源代码3 项目: libcommon   文件: PathShape.java
/**
 * Shape表示内容を定義するPathを設定する
 * @param path
 */
public void setPath(final Path path) {
	mPath.reset();
	if (path != null && !path.isEmpty()) {
		mPath.addPath(path);
	}
}
 
源代码4 项目: youtube-play-icon   文件: Graphics.java
static void inRect(@NonNull Path into, @NonNull float[] pathData) {
  if (!into.isEmpty()) into.rewind();

  into.moveTo(pathData[0], pathData[1]); // top left
  into.lineTo(pathData[2], pathData[3]); // top right
  into.lineTo(pathData[4], pathData[5]); // bottom right
  into.lineTo(pathData[6], pathData[7]); // bottom left
}
 
源代码5 项目: android_9.0.0_r45   文件: PathKeyframes.java
public PathKeyframes(Path path, float error) {
    if (path == null || path.isEmpty()) {
        throw new IllegalArgumentException("The path must not be null or empty");
    }
    mKeyframeData = path.approximate(error);
}
 
源代码6 项目: PathLayoutManager   文件: Keyframes.java
private void initPath(Path path) {
    if (path == null || path.isEmpty()) {
        throw new NullPointerException("path is empty!");
    }
    final PathMeasure pathMeasure = new PathMeasure(path, false);
    mX = new float[0];
    mY = new float[0];
    mAngle = new float[0];
    do {
        final float pathLength = pathMeasure.getLength();
        final int numPoints = (int) (pathLength / PRECISION) + 1;
        final float[] x = new float[numPoints];
        final float[] y = new float[numPoints];
        final float[] angle = new float[numPoints];
        final float[] position = new float[2];
        final float[] tangent = new float[2];
        for (int i = 0; i < numPoints; ++i) {
            final float distance = (i * pathLength) / (numPoints - 1);
            pathMeasure.getPosTan(distance, position, tangent);
            if (position[0] > mMaxX) {
                mMaxX = position[0];
            }
            if (position[1] > mMaxY) {
                mMaxY = position[1];
            }
            x[i] = position[0];
            y[i] = position[1];
            angle[i] = fixAngle((float) (Math.atan2(tangent[1], tangent[0]) * 180F / Math.PI));
        }
        mNumPoints += numPoints;

        float[] tmpX = new float[mX.length + x.length];
        System.arraycopy(mX, 0, tmpX, 0, mX.length);
        System.arraycopy(x, 0, tmpX, mX.length, x.length);
        mX = tmpX;

        float[] tmpY = new float[mY.length + y.length];
        System.arraycopy(mY, 0, tmpY, 0, mY.length);
        System.arraycopy(y, 0, tmpY, mY.length, y.length);
        mY = tmpY;

        float[] tmpAngle = new float[mAngle.length + angle.length];
        System.arraycopy(mAngle, 0, tmpAngle, 0, mAngle.length);
        System.arraycopy(angle, 0, tmpAngle, mAngle.length, angle.length);
        mAngle = tmpAngle;
    } while (pathMeasure.nextContour());
}