List of usage examples for android.graphics Path addPath
public void addPath(Path src)
From source file:com.example.dengue.dengue_android.InkPageIndicator.java
private void drawUnselected(Canvas canvas) { combinedUnselectedPath.rewind();//w w w . j a v a 2 s .c om // draw any settled, revealing or joining dots for (int page = 0; page < pageCount; page++) { int nextXIndex = page == pageCount - 1 ? page : page + 1; Path unselectedPath = getUnselectedPath(page, dotCenterX[page], dotCenterX[nextXIndex], page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page], dotRevealFractions[page]); unselectedPath.addPath(combinedUnselectedPath); combinedUnselectedPath.addPath(unselectedPath); } // draw any retreating joins if (retreatingJoinX1 != INVALID_FRACTION) { Path retreatingJoinPath = getRetreatingJoinPath(); combinedUnselectedPath.addPath(retreatingJoinPath); } canvas.drawPath(combinedUnselectedPath, unselectedPaint); }
From source file:com.skytree.epubtest.BookViewActivity.java
@SuppressLint({ "DrawAllocation", "DrawAllocation" }) @Override/* w ww . j a v a 2s . c o m*/ protected void onDraw(Canvas canvas) { Paint paint = new Paint(); float sl, sr, st, sb; sl = 0; sr = this.getWidth(); float ah = this.arrowHeight; // arrow Height; if (this.isArrowDown) { st = 0; sb = this.getHeight() - ah; } else { st = ah - 10; sb = this.getHeight() - 10; } Path boxPath = new Path(); boxPath.addRoundRect(new RectF(sl, st, sr, sb), 20, 20, Path.Direction.CW); if (arrowPosition <= arrowHeight * 1.5f) { arrowPosition = arrowHeight * 1.5f; } else if (arrowPosition >= this.getWidth() - arrowHeight * 1.5f) { arrowPosition = this.getWidth() - arrowHeight * 1.5f; } Path arrowPath = new Path(); if (isArrowDown) { arrowPath.moveTo(arrowPosition, sb + ah); arrowPath.lineTo((float) (arrowPosition - ah * 0.75), sb - 10); arrowPath.lineTo((float) (arrowPosition + ah * 0.75), sb - 10); arrowPath.close(); } else { arrowPath.moveTo(arrowPosition, 0); arrowPath.lineTo((float) (arrowPosition - ah * 0.75), ah + 10); arrowPath.lineTo((float) (arrowPosition + ah * 0.75), ah + 10); arrowPath.close(); } paint.setColor(this.strokeColor); paint.setStyle(Paint.Style.FILL); boxPath.addPath(arrowPath); canvas.drawPath(boxPath, paint); paint.setColor(this.boxColor); paint.setStyle(Paint.Style.FILL); boxPath.addPath(arrowPath); canvas.save(); float sf = 0.995f; float ox = (this.getWidth() - (this.getWidth() * sf)) / 2.0f; float oy = ((this.getHeight() - arrowHeight) - ((this.getHeight() - arrowHeight) * sf)) / 2.0f; canvas.translate(ox, oy); canvas.scale(sf, sf); canvas.drawPath(boxPath, paint); canvas.restore(); if (layoutChanged) { this.recalcLayout(); layoutChanged = false; } }