Android examples for Graphics:Path
create Tag Path
//package com.java2s; import android.graphics.Path; public class Main { public static Path createTagPath(int aWidth, int aHeight, int aTriangleX, int aTriangleSize, int aXPadding, int aYPadding) { return createTagPath(aWidth, aHeight, aTriangleX, aTriangleSize, aXPadding, aYPadding, false); }// ww w. ja va2 s .co m public static Path createTagPath(int aWidth, int aHeight, int aTriangleX, int aTriangleSize, int aXPadding, int aYPadding, boolean aOrientDown) { Path path = new Path(); float P1x = aXPadding; float P1y = aTriangleSize + aYPadding; float P2x = aTriangleX - aTriangleSize; float P2y = aTriangleSize + aYPadding; float P3x = aTriangleX; float P3y = aYPadding; float P4x = aTriangleX + aTriangleSize; float P4y = aTriangleSize + aYPadding; float P5x = aWidth - aXPadding; float P5y = aTriangleSize + aYPadding; float P6x = aWidth - aXPadding; float P6y = aHeight - aYPadding; float P7x = aXPadding; float P7y = aHeight - aYPadding; if (aOrientDown) { float X = aWidth - aXPadding; float Y = aHeight - aYPadding; P1x = mirror(P1x, X); P2x = mirror(P2x, X); P3x = mirror(P3x, X); P4x = mirror(P4x, X); P5x = mirror(P5x, X); P6x = mirror(P6x, X); P7x = mirror(P7x, X); P1y = mirror(P1y, Y); P2y = mirror(P2y, Y); P3y = mirror(P3y, Y); P4y = mirror(P4y, Y); P5y = mirror(P5y, Y); P6y = mirror(P6y, Y); P7y = mirror(P7y, Y); } path.moveTo(P1x, P1y); path.lineTo(P2x, P2y); path.lineTo(P3x, P3y); path.lineTo(P4x, P4y); path.lineTo(P5x, P5y); path.lineTo(P6x, P6y); path.lineTo(P7x, P7y); path.close(); return path; } private static float mirror(float point, float mirrorLength) { return mirrorLength - (point); } }