Example usage for android.graphics Path close

List of usage examples for android.graphics Path close

Introduction

In this page you can find the example usage for android.graphics Path close.

Prototype

public void close() 

Source Link

Document

Close the current contour.

Usage

From source file:Main.java

public static Path createDownTrianglePath(int aX, int aY, int aWidth, int aHeight) {
    Path path = new Path();

    path.moveTo(aX, aY);//from   w w  w.  j  a  v  a2  s  .  c  om
    path.lineTo(aX + aWidth, aY);
    path.lineTo(aX + (aWidth >> 1), aY + aHeight);
    path.close();

    return path;
}

From source file:Main.java

public static Path createUpTrianglePath(int aX, int aY, int aWidth, int aHeight) {
    Path path = new Path();

    path.moveTo(aX, aY + aHeight);//from   w w  w  .j a  v a2  s . com
    path.lineTo(aX + (aWidth >> 1), aY);
    path.lineTo(aX + aWidth, aY + aHeight);
    path.close();

    return path;
}

From source file:Main.java

/**
 * Helper method to draw a generic triangle onto the canvas
 * @param canvas the canvas being drawn to
 * @param a point 1//from  w  w w  .  j a  va  2s .  c  o m
 * @param b point 2
 * @param c point 3
 */
public static void drawTriangle(Canvas canvas, Point a, Point b, Point c, Paint paint) {

    Path path = new Path();
    path.setFillType(Path.FillType.EVEN_ODD);
    path.moveTo(b.x, b.y);
    path.lineTo(c.x, c.y);
    path.lineTo(a.x, a.y);
    path.close();

    canvas.drawPath(path, paint);
}

From source file:Main.java

private static Path gloss(int size) {
    Path gloss = new Path();
    gloss.moveTo(0, size);/*from ww w. j  a va  2  s .c  o  m*/
    gloss.cubicTo(0, size, size * 3 / 4, size * 3 / 4, size, 0);
    gloss.lineTo(0, 0);
    gloss.close();
    return gloss;
}

From source file:Main.java

public static void drawBorder(int width, int height, Canvas canvas, Paint paint, Path workingPath) {

    paint.setStyle(Paint.Style.STROKE);
    workingPath.reset();//from www.ja va2  s  .  co m
    workingPath.moveTo(0, 0);
    workingPath.lineTo(width, 0);
    workingPath.lineTo(width, height);
    workingPath.lineTo(0, height);
    workingPath.lineTo(0, 0);
    workingPath.close();

    canvas.drawPath(workingPath, paint);

}

From source file:Main.java

private static void drawAntiRoundRect(Canvas canvas, Paint paint, int radius, RectF rect, int direction) {
    if (direction == 1) {
        Path path = new Path();
        path.moveTo(rect.left, rect.top);
        path.lineTo(rect.left, rect.top + radius);
        path.addArc(new RectF(rect.left, rect.top, rect.left + radius * 2, rect.top + radius * 2), 180, 90);
        path.lineTo(rect.left, rect.top);
        path.close();
        canvas.drawPath(path, paint);/*w  ww . j  ava  2s.c  o m*/
    } else if (direction == 2) {
        Path path = new Path();
        path.moveTo(rect.right, rect.top);
        path.lineTo(rect.right - radius, rect.top);
        path.addArc(new RectF(rect.right - 2 * radius, rect.top, rect.right, rect.top + radius * 2), 270, 90);
        path.lineTo(rect.right, rect.top);
        path.close();
        canvas.drawPath(path, paint);
    } else if (direction == 3) {
        Path path = new Path();
        path.moveTo(rect.right, rect.bottom);
        path.lineTo(rect.right, rect.bottom - radius);
        path.addArc(new RectF(rect.right - 2 * radius, rect.bottom - 2 * radius, rect.right, rect.bottom), 0,
                90);
        path.lineTo(rect.right, rect.bottom);
        path.close();
        canvas.drawPath(path, paint);
    } else if (direction == 4) {
        Path path = new Path();
        path.moveTo(rect.left, rect.bottom);
        path.lineTo(rect.left + radius, rect.bottom);
        path.addArc(new RectF(rect.left, rect.bottom - 2 * radius, rect.left + 2 * radius, rect.bottom), 90,
                90);
        path.lineTo(rect.left, rect.bottom);
        path.close();
        canvas.drawPath(path, paint);
    }
}

From source file:Main.java

private static Path drawPaddingLeft() {
    //Draw the padding Left
    Path paddingLeft = new Path();
    paddingLeft.moveTo(coord_A[0], coord_A[1]); /*A*/
    paddingLeft.lineTo(coord_B[0], coord_B[1]); /*B*/
    paddingLeft.lineTo(coord_C[0], coord_C[1]); /*C*/
    paddingLeft.lineTo(coord_D[0], coord_D[1]); /*D*/
    paddingLeft.lineTo(coord_E[0], coord_E[1]); /*E*/
    paddingLeft.lineTo(coord_F[0], coord_F[1]); /*F*/
    paddingLeft.close();

    return paddingLeft;
}

From source file:Main.java

private static Path drawPaddingRight() {
    //Draw the padding Right
    Path paddingRight = new Path();
    paddingRight.moveTo(coord_A[0], coord_A[1]); /*A*/
    paddingRight.lineTo(coord_F[0], coord_F[1]); /*F*/
    paddingRight.lineTo(coord_G[0], coord_G[1]); /*G*/
    paddingRight.lineTo(coord_H[0], coord_H[1]); /*H*/
    paddingRight.lineTo(coord_I[0], coord_I[1]); /*I*/
    paddingRight.lineTo(coord_J[0], coord_J[1]); /*J*/
    paddingRight.close();

    return paddingRight;
}

From source file:Main.java

static Path getWavePath(float width, float height, float amplitude, float shift, float divide) {
    Path path = new Path();
    float quadrant = height - amplitude;
    float x, y;/*  w  w w  .  j  a va  2  s. c  o m*/
    path.moveTo(0, 0);
    path.lineTo(0, quadrant);
    for (int i = 0; i < width + 10; i = i + 10) {
        x = (float) i;
        y = quadrant + amplitude * (float) Math.sin(((i + 10) * Math.PI / 180) / divide + shift);
        path.lineTo(x, y);
    }
    path.lineTo(width, 0);
    path.close();
    return path;
}

From source file:Main.java

private static Path drawPadding() {
    //Draw the padding
    Path padding = new Path();
    padding.moveTo(coord_A[2], coord_A[3]); /*A*/
    padding.lineTo(coord_B[2], coord_B[3]); /*B*/
    padding.lineTo(coord_C[2], coord_C[3]); /*C*/
    padding.lineTo(coord_D[2], coord_D[3]); /*D*/
    padding.lineTo(coord_E[2], coord_E[3]); /*E*/
    padding.lineTo(coord_F[2], coord_F[3]); /*F*/
    padding.lineTo(coord_G[2], coord_G[3]); /*G*/
    padding.lineTo(coord_H[2], coord_H[3]); /*H*/
    padding.lineTo(coord_I[2], coord_I[3]); /*I*/
    padding.lineTo(coord_J[2], coord_J[3]); /*J*/
    padding.close();

    return padding;
}