private static Path getTrianglePath(int x1, int y1, int width) { final Path path = new Path(); path.moveTo(x1, y1); path.lineTo(x1 + width, y1); path.lineTo(x1, y1 + width); return path; } }
private void init(Context context) { float density = context.getResources().getDisplayMetrics().density; mRadius = 2.0f * density; mRoundedRectPath = new Path(); mRectF = new RectF(); }
private static Path createQuad(float controlX, float controlY) { final Path path = new Path(); path.moveTo(0.0f, 0.0f); path.quadTo(controlX, controlY, 1.0f, 1.0f); return path; }
public void setMarquee(boolean marquee) { if (marquee == (mMarqueeLine != null)) { return; } mMarqueeLine = marquee ? new Path() : null; mMarqueeHandler = marquee ? new Handler(Looper.getMainLooper()) : null; mMarqueeSize = 0; mMarqueeNext = 0; }
SquigglySpan(Resources resources) { squigglyPaint = new Paint(Paint.ANTI_ALIAS_FLAG); squigglyPaint.setStyle(Paint.Style.STROKE); squigglyPaint.setColor(resources.getColor(R.color.leak_canary_leak)); float strokeWidth = resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_stroke_width); squigglyPaint.setStrokeWidth(strokeWidth); halfStrokeWidth = strokeWidth / 2; amplitude = resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_amplitude); periodDegrees = resources.getDimensionPixelSize(R.dimen.leak_canary_squiggly_span_period_degrees); path = new Path(); float waveHeight = 2 * amplitude + strokeWidth; halfWaveHeight = waveHeight / 2; referenceColor = resources.getColor(R.color.leak_canary_reference); }
private void init() { // A new paint with the style as stroke. mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(textColor); mPaint.setStrokeWidth(5.0f); mPaint.setStyle(Paint.Style.STROKE); mPath = new Path(); } }
public HeaderDrawable(Context context){ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(ThemeUtil.colorPrimary(context, 0)); mPaint.setStyle(Paint.Style.FILL); mPath = new Path(); }
private static Path createCubic(float controlX1, float controlY1, float controlX2, float controlY2) { final Path path = new Path(); path.moveTo(0.0f, 0.0f); path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0f, 1.0f); return path; } }
/** * Initialize the {@code Path} objects with the appropriate values. */ private void initPaths() { mCirclePath = new Path(); mCirclePath.addArc(mCircleRectF, mStartAngle, mTotalCircleDegrees); mCircleProgressPath = new Path(); mCircleProgressPath.addArc(mCircleRectF, mStartAngle, mProgressDegrees); }
public BezierCircleHeader(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mSpinnerStyle = SpinnerStyle.Scale; final View thisView = this; thisView.setMinimumHeight(DensityUtil.dp2px(100)); mBackPaint = new Paint(); mBackPaint.setColor(0xff11bbff); mBackPaint.setAntiAlias(true); mFrontPaint = new Paint(); mFrontPaint.setColor(0xffffffff); mFrontPaint.setAntiAlias(true); mOuterPaint = new Paint(); mOuterPaint.setAntiAlias(true); mOuterPaint.setColor(0xffffffff); mOuterPaint.setStyle(Paint.Style.STROKE); mOuterPaint.setStrokeWidth(DensityUtil.dp2px(2f)); mPath = new Path(); }
public static Path createPath(PointF startPoint, PointF endPoint, PointF cp1, PointF cp2) { Path path = new Path(); path.moveTo(startPoint.x, startPoint.y); if (cp1 != null && cp2 != null && (cp1.length() != 0 || cp2.length() != 0)) { path.cubicTo( startPoint.x + cp1.x, startPoint.y + cp1.y, endPoint.x + cp2.x, endPoint.y + cp2.y, endPoint.x, endPoint.y); } else { path.lineTo(endPoint.x, endPoint.y); } return path; }
/** * @param pathData The string representing a path, the same as "d" string in svg file. * @return the generated Path object. */ public static Path createPathFromPathData(String pathData) { Path path = new Path(); PathDataNode[] nodes = createNodesFromPathData(pathData); if (nodes != null) { try { PathDataNode.nodesToPath(nodes, path); } catch (RuntimeException e) { throw new RuntimeException("Error in parsing " + pathData, e); } return path; } return null; }
@Implementation protected void drawPath(Path path, Paint paint) { pathPaintEvents.add(new PathPaintHistoryEvent(new Path(path), new Paint(paint))); separateLines(); ShadowPath shadowPath = Shadow.extract(path); appendDescription("Path " + shadowPath.getPoints().toString()); }
@Implementation protected static Path createPathFromPathData(String pathData) { Path path = new Path(); PathDataNode[] nodes = createNodesFromPathData(pathData); if (nodes != null) { PathDataNode.nodesToPath(nodes, path); return path; } return null; }
@Test public void testReset() throws Exception { Path path = new Path(); path.moveTo(0, 3); path.lineTo(2, 3); path.quadTo(2, 3, 4, 5); path.reset(); ShadowPath shadowPath = shadowOf(path); List<ShadowPath.Point> points = shadowPath.getPoints(); assertEquals(0, points.size()); }
@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()); }
@Test public void testLineTo() throws Exception { Path path = new Path(); path.lineTo(2, 3); path.lineTo(3, 4); List<ShadowPath.Point> lineToPoints = shadowOf(path).getPoints(); assertEquals(2, lineToPoints.size()); assertEquals(new ShadowPath.Point(2, 3, LINE_TO), lineToPoints.get(0)); assertEquals(new ShadowPath.Point(3, 4, LINE_TO), lineToPoints.get(1)); }
@Test public void testMoveTo() throws Exception { Path path = new Path(); path.moveTo(2, 3); path.moveTo(3, 4); List<ShadowPath.Point> moveToPoints = shadowOf(path).getPoints(); assertEquals(2, moveToPoints.size()); assertEquals(new ShadowPath.Point(2, 3, MOVE_TO), moveToPoints.get(0)); assertEquals(new ShadowPath.Point(3, 4, MOVE_TO), moveToPoints.get(1)); }
@Test public void setConvexPath_doesNothing() { final Outline outline = new Outline(); outline.setConvexPath(new Path()); } }