List of usage examples for android.graphics Path close
public void close()
From source file:Main.java
private static Path drawOutLine() { //Draw the outline Path outline = new Path(); outline.moveTo(coord_A[0], coord_A[1]); /*A*/ outline.lineTo(coord_B[0], coord_B[1]); /*B*/ outline.lineTo(coord_C[0], coord_C[1]); /*C*/ outline.lineTo(coord_D[0], coord_D[1]); /*D*/ outline.lineTo(coord_E[0], coord_E[1]); /*E*/ outline.lineTo(coord_F[0], coord_F[1]); /*F*/ outline.lineTo(coord_G[0], coord_G[1]); /*G*/ outline.lineTo(coord_H[0], coord_H[1]); /*H*/ outline.lineTo(coord_I[0], coord_I[1]); /*I*/ outline.lineTo(coord_J[0], coord_J[1]); /*J*/ outline.moveTo(coord_A[2], coord_A[3]); /*A*/ outline.lineTo(coord_B[2], coord_B[3]); /*J*/ outline.lineTo(coord_C[2], coord_C[3]); /*I*/ outline.lineTo(coord_D[2], coord_D[3]); /*H*/ outline.lineTo(coord_E[2], coord_E[3]); /*G*/ outline.lineTo(coord_F[2], coord_F[3]); /*F*/ outline.lineTo(coord_G[2], coord_G[3]); /*E*/ outline.lineTo(coord_H[2], coord_H[3]); /*D*/ outline.lineTo(coord_I[2], coord_I[3]); /*C*/ outline.lineTo(coord_J[2], coord_J[3]); /*B*/ outline.close(); return outline; }
From source file:com.mtomczak.nausicaa.DockingView.java
/** * Encode a list of x,y coords into a path * * @param points Points to encode/*from ww w.ja v a2s .c o m*/ * @return The encoded path */ private Path encodePath(float[] points) { Path path = new Path(); path.moveTo(points[0], points[1]); for (int i = 2; i < points.length; i += 2) { path.lineTo(points[i], points[i + 1]); } path.close(); path.setFillType(Path.FillType.WINDING); return path; }
From source file:piuk.blockchain.android.util.ViewPagerTabs.java
@Override protected void onDraw(final Canvas canvas) { super.onDraw(canvas); final int viewWidth = getWidth(); final int viewHalfWidth = viewWidth / 2; final int viewBottom = getHeight(); final float density = getResources().getDisplayMetrics().density; final float spacing = 32 * density; final Path path = new Path(); path.moveTo(viewHalfWidth, viewBottom - 5 * density); path.lineTo(viewHalfWidth + 5 * density, viewBottom); path.lineTo(viewHalfWidth - 5 * density, viewBottom); path.close(); paint.setColor(Color.WHITE);/*from w ww. java2 s . c o m*/ canvas.drawPath(path, paint); paint.setTypeface(Typeface.DEFAULT_BOLD); final float y = getPaddingTop() + -paint.getFontMetrics().top; for (int i = 0; i < labels.size(); i++) { final String label = labels.get(i); paint.setTypeface(i == pagePosition ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); paint.setColor(i == pagePosition ? Color.BLACK : Color.DKGRAY); final float x = viewHalfWidth + (maxWidth + spacing) * (i - pageOffset); final float labelWidth = paint.measureText(label); final float labelHalfWidth = labelWidth / 2; final float labelLeft = x - labelHalfWidth; final float labelVisibleLeft = labelLeft >= 0 ? 1f : 1f - (-labelLeft / labelWidth); final float labelRight = x + labelHalfWidth; final float labelVisibleRight = labelRight < viewWidth ? 1f : 1f - ((labelRight - viewWidth) / labelWidth); final float labelVisible = Math.min(labelVisibleLeft, labelVisibleRight); paint.setAlpha((int) (labelVisible * 255)); canvas.drawText(label, labelLeft, y, paint); } }
From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java
private Path createOutlinePath(float perpendicularHeight) { Path path = new Path(); if (settings.isBottom()) { if (settings.isGravityLeft()) { path.moveTo(getPaddingLeft(), getPaddingRight()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(width - getPaddingRight(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } else {//from w ww . j a v a 2 s .co m path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.close(); } } else { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } else { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(getPaddingLeft(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } } return path; }
From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java
private Path createClipPath(float perpendicularHeight) { Path path = new Path(); if (settings.isBottom()) { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight() + EPSILON, height - perpendicularHeight - getPaddingBottom() + EPSILON); path.lineTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON); path.close(); } else {/*www . j a va 2 s. co m*/ path.moveTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - perpendicularHeight - getPaddingBottom() + EPSILON); path.close(); } } else { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() + perpendicularHeight - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON); path.lineTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON); path.close(); } else { path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() + perpendicularHeight - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON); path.close(); } } return path; }
From source file:com.github.czy1121.view.CornerLabelView.java
private Path calcPath() { Path path = new Path(); path.moveTo(-mHeight, 0);//from www . j a va 2 s. c o m path.lineTo(mHeight, 0); int factor = mIsTop ? -1 : 1; if (mIsTriangle) { path.lineTo(0, factor * mHeight); } else { int lineHeight = factor * (int) (mPaddingCenter + mPaddingBottom + mText1.height); path.lineTo(mHeight + lineHeight, lineHeight); path.lineTo(-mHeight + lineHeight, lineHeight); } path.close(); return path; }
From source file:com.astuetz.PagerSlidingTabStripCustom.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/* www . j a v a 2s .co m*/ } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, start interpolating left and right coordinates between current and next tab if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); //draw triangle float bianchang = indicatorHeight + 10; float x1 = (lineRight + lineLeft) / 2; float y1 = height - bianchang; float x2 = x1 + bianchang * 2; float y2 = y1 + bianchang; float x3 = x1 - bianchang * 2; float y3 = y1 + bianchang; Path path = new Path(); path.moveTo(x1, y1); path.lineTo(x2, y2); path.lineTo(x3, y3); path.close(); canvas.drawPath(path, rectPaint); // draw underline tabcontent rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw divider tab dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.frapim.windwatch.Notifier.java
private Path getArrowPath(float degrees) { Path path = new Path(); int leftX = (mBigIconSize / 2) - (mArrowWidth / 2); int leftHeadX = leftX - mArrowWidth; int rightX = (mBigIconSize / 2) + (mArrowWidth / 2); int rightHeadX = rightX + mArrowWidth; path.moveTo(leftX, mArrowHeight); // bottom left path.lineTo(leftX, mArrowHeadHeight); // left, arrow head start path.lineTo(leftHeadX, mArrowHeadHeight); // left, arrow head end path.lineTo(mBigIconSize / 2, 0); // top path.lineTo(rightHeadX, mArrowHeadHeight); // right, arrow head end path.lineTo(rightX, mArrowHeadHeight); // right, arrow head start path.lineTo(rightX, mArrowHeight); // bottom right path.lineTo(leftX, mArrowHeight); // bottom left path.close(); Matrix translateMatrix = new Matrix(); translateMatrix.postTranslate(0, 30); path.transform(translateMatrix);//from ww w . j a va2 s. c om RectF bounds = new RectF(); path.computeBounds(bounds, true); Matrix rotateMatrix = new Matrix(); rotateMatrix.postRotate(degrees, (bounds.right + bounds.left) / 2, (bounds.bottom + bounds.top) / 2); path.transform(rotateMatrix); return path; }
From source file:com.richtodd.android.quiltdesign.block.PaperPiecedBlockPiece.java
private Path createPath(int width, int height) { // Log.i(TAG, "pathCreate(" + width + "," + height + ")"); Path path = null; for (PointF point : getPoints(width, height)) { // Log.i(TAG, " point = " + point.x + ", " + point.y); if (path == null) { path = new Path(); path.moveTo(point.x, point.y); } else {/* w w w . j a va2 s . co m*/ path.lineTo(point.x, point.y); } } if (path != null) { path.close(); } return path; }
From source file:com.kmagic.solitaire.DrawMaster.java
/** * Draw a heart/* www . j a v a 2 s. co m*/ * @param canvas canvas to draw on * @param width width of the heart * @param height height of the heart */ public void drawHeart(final Canvas canvas, final float width, final float height) { final Paint paint = getRedPaint(); final float width_half = width / 2; final float width_quarter = width / 4; final float height_quarter = height / 4; final float height_third = height / 3; canvas.drawCircle(width_quarter, height_quarter, width_quarter, paint); canvas.drawCircle(width_quarter * 3, height_quarter, width_quarter, paint); final Path path = new Path(); path.moveTo(0, height_third); path.lineTo(width_half, height); path.lineTo(width, height_third); path.lineTo(0, height_third); path.close(); canvas.drawPath(path, paint); }