Refine search
Paint wallpaint = new Paint(); wallpaint.setColor(Color.GRAY); wallpaint.setStyle(Style.FILL); Path wallpath = new Path(); wallpath.reset(); // only needed when reusing this path for a new build wallpath.moveTo(x[0], y[0]); // used for first point wallpath.lineTo(x[1], y[1]); wallpath.lineTo(x[2], y[2]); wallpath.lineTo(x[3], y[3]); wallpath.lineTo(x[0], y[0]); // there is a setLastPoint action but i found it not to work as expected canvas.drawPath(wallpath, wallpaint);
Shape shape = new Shape() { Path path = new Path(); @Override protected void onResize(float width, float height) { path.reset(); path.lineTo(width - height / 2, 0); path.lineTo(width, height / 2); path.lineTo(width - height / 2, height); path.lineTo(0, height); path.close(); } @Override public void draw(Canvas canvas, Paint paint) { canvas.drawPath(path, paint); } }; ShapeDrawable d = new ShapeDrawable(shape); d.getPaint().setColor(0xff6699bb); someView.setBackgroundDrawable(d);
super(c); context=c; mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); circlePaint = new Paint(); circlePath = new Path(); circlePaint.setAntiAlias(true); circlePaint.setColor(Color.BLUE); mPath.reset(); mPath.moveTo(x, y); mX = x; mY = y; mY = y; circlePath.reset(); circlePath.addCircle(mX, mY, 30, Path.Direction.CW); mPath.lineTo(mX, mY); circlePath.reset(); mPath.reset();
private Path path = new Path(); @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); // compute the path float halfWidth = w / 2f; float halfHeight = h / 2f; float centerX = halfWidth; float centerY = halfHeight; path.reset(); path.addCircle(centerX, centerY, Math.min(halfWidth, halfHeight), Path.Direction.CW); path.close(); } @Override protected void dispatchDraw(Canvas canvas) { int save = canvas.save(); canvas.clipPath(circlePath); super.dispatchDraw(canvas); canvas.restoreToCount(save); }
private Bitmap fgBitmap; private RectF fullRect = new RectF(); private Path clipPath = new Path(); clipPath.reset(); clipPath.setLastPoint(getWidth() / 2, getHeight() / 2); clipPath.lineTo(getWidth() / 2, getHeight()); clipPath.arcTo(fullRect, -90, angle); clipPath.lineTo(getWidth() / 2, getHeight() / 2); c.clipPath(clipPath);
public void drawBrzierLine(Canvas mCanvas, float xi, float yi, float xd, float yd) { Point start = new Point((int) xi, (int) yi); Point end = new Point((int) xd, (int) yd); Path mPath = new Path(); mPath.reset(); mPath.moveTo(start.x, start.y); mPath.quadTo(start.x, start.y, end.x, end.y); mCanvas.drawPath(mPath, mPaint); }
Path p = new Path(); Point mid = new Point(); // ... Point start = ...; Point end = ...; mid.set((start.x + end.x) / 2, (start.y + end.y) / 2); // Draw line connecting the two points: p.reset(); p.moveTo(start.x, start.y); p.quadTo((start.x + mid.x) / 2, start.y, mid.x, mid.y); p.quadTo((mid.x + end.x) / 2, end.y, end.x, end.y); canvas.drawPath(p, pLineBorder); canvas.drawPath(p, pLine);
private RectF mSrcRect = new RectF(); private RectF mDstRect = new RectF(); private Path mClipPath = new Path(); mSrcRect.set(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight()); getImageMatrix().mapRect(mDstRect, mSrcRect); mClipPath.reset(); mClipPath.addRoundRect(mDstRect, radius, radius, Path.Direction.CW); canvas.clipPath(mClipPath);
Path path = new Path(); float size; protected void onResize(float width, float height) { float radius = Math.min(width, height) / 2; path.reset(); path.moveTo(width / 2 - size, height / 2 - radius / 2); path.rLineTo(size, -size); path.rLineTo(size, size); path.moveTo(width / 2 - size, height / 2 + radius / 2); path.rLineTo(size, size); path.rLineTo(size, -size);