Example usage for android.graphics Path Path

List of usage examples for android.graphics Path Path

Introduction

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

Prototype

public Path() 

Source Link

Document

Create an empty path

Usage

From source file:Main.java

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

    path.moveTo(aX + aWidth, aY);/*from  w ww .j av  a  2 s. com*/
    path.lineTo(aX, aY + (aHeight >> 1));
    path.lineTo(aX + aWidth, aY + aHeight);

    return path;
}

From source file:Main.java

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

    path.moveTo(aX, aY);/*from   w w  w .ja v a2s. com*/
    path.lineTo(aX + (aWidth >> 1), aY + aHeight);
    path.lineTo(aX + aWidth, aY);

    return path;
}

From source file:Main.java

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

    path.moveTo(aX, aY);/* w w  w  .  j a  v a2s  . c  o m*/
    path.lineTo(aX + aWidth, aY + (aHeight >> 1));
    path.lineTo(aX, aY + aHeight);

    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 va2s  .  c o  m
    path.lineTo(aX + (aWidth >> 1), aY);
    path.lineTo(aX + aWidth, aY + aHeight);
    path.close();

    return path;
}

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 ava  2  s.c o m
    path.lineTo(aX + aWidth, aY);
    path.lineTo(aX + (aWidth >> 1), aY + aHeight);
    path.close();

    return path;
}

From source file:Main.java

public static Path addRoundPath3(int width, int height, float radius) {
    Path path = new Path();
    path.addRoundRect(new RectF(0, 0, width, height), radius, radius, Path.Direction.CW);
    return path;/*from w  w  w.  j a v  a2 s  .c o m*/
}

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;//from  ww w. j  av a2  s .  co 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

public static void drawImage(Canvas canvas, Paint paint, Bitmap bitmap, float x, float y, float r) {
    canvas.save();//  w ww. j  av  a  2s. co  m
    Path path = new Path();
    path.addCircle(x, y, r, Path.Direction.CCW);
    canvas.clipPath(path);
    canvas.drawBitmap(bitmap, x - r, y - r, paint);
    canvas.restore();
}

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();/*from www  . ja v  a  2 s .  c  o  m*/
        canvas.drawPath(path, paint);
    } 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

public static Bitmap getRoundedCircleBitmap(Bitmap scaleBitmapImage) {
    int targetWidth = 150;
    int targetHeight = 150;
    Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(targetBitmap);
    Path path = new Path();
    path.addCircle(((float) targetWidth - 1) / 2, ((float) targetHeight - 1) / 2,
            (Math.min(((float) targetWidth), ((float) targetHeight)) / 2), Path.Direction.CCW);

    canvas.clipPath(path);//from   w ww .  ja v a2 s  .  c  o m
    Bitmap sourceBitmap = scaleBitmapImage;
    canvas.drawBitmap(sourceBitmap, new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()),
            new Rect(0, 0, targetWidth, targetHeight), null);
    return targetBitmap;
}