use of android.graphics.Path in project JamsMusicPlayer by psaravan.
the class Pin method init.
private void init() {
mPath = new Path();
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStyle(Paint.Style.FILL);
setColor(mPinColor);
}
use of android.graphics.Path in project Genius-Android by qiujuer.
the class BalloonMarkerDrawable method computePath.
private void computePath(Rect bounds) {
final float currentScale = mCurrentScale;
final Path path = mPath;
final RectF rect = mRect;
final Matrix matrix = mMatrix;
path.reset();
int totalSize = Math.min(bounds.width(), bounds.height());
float initial = mClosedStateSize;
float currentSize = initial + ((float) totalSize - initial) * currentScale;
float halfSize = currentSize / 2f;
float inverseScale = 1f - currentScale;
float cornerSize = halfSize * inverseScale;
float[] corners = new float[] { halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize, cornerSize };
rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize);
path.addRoundRect(rect, corners, Path.Direction.CCW);
matrix.reset();
matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize);
matrix.postTranslate((bounds.width() - currentSize) / 2, 0);
float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
matrix.postTranslate(0, hDiff);
path.transform(matrix);
}
use of android.graphics.Path in project robolectric by robolectric.
the class ShadowCanvasTest method drawPath_shouldRecordThePathAndThePaint.
@Test
public void drawPath_shouldRecordThePathAndThePaint() throws Exception {
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.lineTo(10, 10);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setAlpha(7);
canvas.drawPath(path, paint);
// changing the values on this Paint shouldn't affect recorded painted path
paint.setColor(Color.BLUE);
paint.setAlpha(8);
ShadowCanvas shadow = shadowOf(canvas);
assertThat(shadow.getPathPaintHistoryCount()).isEqualTo(1);
ShadowPath drawnPath = shadowOf(shadow.getDrawnPath(0));
assertEquals(drawnPath.getPoints().get(0), new ShadowPath.Point(10, 10, LINE_TO));
Paint drawnPathPaint = shadow.getDrawnPathPaint(0);
assertThat(drawnPathPaint.getColor()).isEqualTo(Color.RED);
assertThat(drawnPathPaint.getAlpha()).isEqualTo(7);
}
use of android.graphics.Path in project robolectric by robolectric.
the class ShadowCanvasTest method resetCanvasHistory_shouldClearTheHistoryAndDescription.
@Test
public void resetCanvasHistory_shouldClearTheHistoryAndDescription() throws Exception {
Canvas canvas = new Canvas();
canvas.drawPath(new Path(), new Paint());
canvas.drawText("hi", 1, 2, new Paint());
ShadowCanvas shadow = shadowOf(canvas);
shadow.resetCanvasHistory();
assertThat(shadow.getPathPaintHistoryCount()).isEqualTo(0);
assertThat(shadow.getTextHistoryCount()).isEqualTo(0);
assertEquals("", shadow.getDescription());
}
use of android.graphics.Path in project robolectric by robolectric.
the class ShadowOutlineTest method setConvexPath_doesNothing.
@Test
public void setConvexPath_doesNothing() {
final Outline outline = new Outline();
outline.setConvexPath(new Path());
}
Aggregations