Search in sources :

Example 96 with Path

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);
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Example 97 with Path

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);
}
Also used : Path(android.graphics.Path) RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) Paint(android.graphics.Paint)

Example 98 with Path

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);
}
Also used : Path(android.graphics.Path) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Test(org.junit.Test)

Example 99 with Path

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());
}
Also used : Path(android.graphics.Path) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Test(org.junit.Test)

Example 100 with Path

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());
}
Also used : Path(android.graphics.Path) Outline(android.graphics.Outline) Test(org.junit.Test)

Aggregations

Path (android.graphics.Path)622 Paint (android.graphics.Paint)233 RectF (android.graphics.RectF)141 Canvas (android.graphics.Canvas)39 Rect (android.graphics.Rect)39 Matrix (android.graphics.Matrix)36 TextPaint (android.text.TextPaint)27 Bitmap (android.graphics.Bitmap)26 ObjectAnimator (android.animation.ObjectAnimator)18 LinearGradient (android.graphics.LinearGradient)18 PointF (android.graphics.PointF)18 Point (android.graphics.Point)15 RadialGradient (android.graphics.RadialGradient)15 View (android.view.View)15 Animator (android.animation.Animator)13 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)12 PathMeasure (android.graphics.PathMeasure)11 PropertyValuesHolder (android.animation.PropertyValuesHolder)10 InflateException (android.view.InflateException)10 Test (org.junit.Test)10