Path computeBounds - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Path computeBounds method.

This code example shows how to use the following methods:close, computeBounds, lineTo, moveTo, quadTo
 
    /** 
     * Updates the internal data required to draw. 
     */ 
    private void update() { 
        mPath.reset();
        mPath.moveTo(mX1, mY1);
        mPath.quadTo(mCtrlx, mCtrly, mX2, mY2);
         
        mPath.computeBounds(rectBuffer, false);
        mRegion = new Region((int)rectBuffer.left, (int)rectBuffer.top, (int)rectBuffer.right, (int)rectBuffer.bottom);
         
        mPath.lineTo(mX2 + 1, mY2);
        mPath.quadTo(mCtrlx + 1, mCtrly, mX1 + 1, mY1);
        mPath.close();
         
        mRegion.setPath(mPath, mRegion);
    } 
     
    /** 
8
CodeRank
This code example shows how to use the following methods:close, computeBounds, cubicTo, lineTo, moveTo
 
    /** 
     * Updates the internal data required to draw. 
     */ 
    private void update() { 
        mPath.reset();
        mPath.moveTo(mX1, mY1);
        mPath.cubicTo(mCtrlx1, mCtrly1, mCtrlx2, mCtrly2, mX2, mY2);
         
        RectF rect = new RectF();
        mPath.computeBounds(rect, false);
        mRegion = new Region((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom);
        regionBuffer.set(mRegion);
         
        mPath.lineTo(mX2 + 1, mY2);
        mPath.cubicTo(mCtrlx2 + 1, mCtrly2, mCtrlx1 + 1, mCtrly1, mX1 + 1, mY1);
        mPath.close();
 
        mRegion.setPath(mPath, mRegion);
    } 

8
CodeRank
This code example shows how to use the following methods:computeBounds, transform
//            int seg2 = iterator2.currentSegment(d2); 
//            if (seg1 != seg2) { 
//                return false; 
//            } 
//            if (!Arrays.equals(d1, d2)) { 
//                return false; 
//            } 
//            iterator1.next(); 
//            iterator2.next(); 
//            done = iterator1.isDone() && iterator2.isDone(); 
//        } 
        return true; 
    } 
     
    /** 
     * Creates and returns a translated shape. 
     *  
     * @param shape 
     *            the shape (<code>null</code> not permitted). 
     * @param transX 

7
CodeRank
This code example shows how to use the following methods:computeBounds, cubicTo, moveTo
            mPathPaint.setAntiAlias(true);
            mPathPaint.setColor(0xff0000ff);
            mPathPaint.setStrokeWidth(5.0f);
            mPathPaint.setStyle(Paint.Style.FILL);
 
            mPath = new Path();
            mPath.moveTo(0.0f, 0.0f);
            mPath.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
            mPath.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
            mPath.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
 
            mPath.computeBounds(mPathBounds, true);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawARGB(255, 255, 255, 255);
 
            mPathPaint.setColor(0xff0000ff);
7
CodeRank
This code example shows how to use the following methods:computeBounds, transform
     * {@inheritDoc} 
     */ 
    public void translate(float x, float y) {
        Matrix mat = new Matrix();
        mat.postTranslate(x, y);
        mPath.transform(mat);
        update(); 
    } 
     
    /** 
     * Appends the specified point to this polygon. 
     * @param x The x-coordinate of specified point 
     * @param y The y-coordinate of specified point 
     */ 
    public void addPoint(float x, float y) {
        if (mFirstPoint) {
            mPath.moveTo(x, y);
        } else { 
            mPath.lineTo(x, y);
        } 

6
CodeRank
This code example shows how to use the following methods:computeBounds, cubicTo, moveTo
            mPathPaint.setAntiAlias(true);
            mPathPaint.setColor(0xff0000ff);
            mPathPaint.setStrokeWidth(5.0f);
            mPathPaint.setStyle(Paint.Style.FILL);
 
            mPath = new Path();
            mPath.moveTo(0.0f, 0.0f);
            mPath.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
            mPath.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
            mPath.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
 
            mPath.computeBounds(mPathBounds, true);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawARGB(255, 255, 255, 255);
 
            mPathPaint.setColor(0xff0000ff);
6
CodeRank
This code example shows how to use the following methods:close, computeBounds
 
    /** 
     * Closes path. 
     */ 
    public void closePath() { 
        mPath.close();
        update(); 
    } 
 
    /** 
     * Clears all lines and curve. 
     */ 
    public void reset() { 
        mPath.reset();
        update(); 
    } 
 
    /** 
     * Returns x-coordinate of shape bound. 
     * @return x-coordinate of shape bound 

6
CodeRank
This code example shows how to use the following methods:computeBounds
 
public class GliphEnter extends Gliph { 
    private static final float WEIGHT_NORMAL = 5f;
    private static final float WEIGHT_BOLD   = 10f;
 
    @Override 
    protected final void initialize(Path path, boolean bold) {
        float h=20f;
        float b = bold ? WEIGHT_BOLD : WEIGHT_NORMAL;
        path.moveTo(   0f, -b/2);
        path.lineTo(   0f,   -h);
        path.lineTo( -60f,   0f);
        path.lineTo(   0f,    h);
        path.lineTo(   0f,  b/2);
        path.lineTo(  70f,  b/2);
        path.lineTo(  70f,   -h);
        path.lineTo(70f-b,   -h);
        path.lineTo(70f-b, -b/2);
 
        path.close();
6
CodeRank
This code example shows how to use the following methods:computeBounds
 
public class GliphSpace extends Gliph { 
    private static final float WEIGHT_NORMAL = 5f;
    private static final float WEIGHT_BOLD   = 10f;
 
    @Override 
    protected final void initialize(Path path, boolean bold) {
        float h=20f, w=120f;
        float b = bold ? WEIGHT_BOLD : WEIGHT_NORMAL;
 
        path.moveTo(   0f,   0f);
 
        path.lineTo(    w,   0f);
        path.lineTo(    w,   -h);
        path.lineTo(  w-b,   -h);
        path.lineTo(  w-b,   -b);
        path.lineTo(    b,   -b);
        path.lineTo(    b,   -h);
        path.lineTo(   0f,   -h);
 
6
CodeRank
This code example shows how to use the following methods:computeBounds, transform
	public static Bitmap drawToBitmap(final Path arrowPath, final Path arrowPeakPath){
		final Bitmap b = Bitmap.createBitmap(48, 48, Config.ARGB_8888);
		final Canvas c = new Canvas(b);
 
		final RectF boundsPath = new RectF();
		arrowPath.computeBounds(boundsPath, true);
		final RectF boundsOverall = new RectF();
		arrowPath.computeBounds(boundsOverall, true);
 
		boundsOverall.bottom = Math.max(boundsOverall.bottom, boundsPath.bottom);
		boundsOverall.top = Math.min(boundsOverall.top, boundsPath.top);
		boundsOverall.left = Math.min(boundsOverall.left, boundsPath.left);
		boundsOverall.right = Math.max(boundsOverall.right, boundsPath.right);
 
		final float width = boundsOverall.right - boundsOverall.left;
		final float height = boundsOverall.top - boundsOverall.bottom;
		final float biggerSide = Math.max(width, height);
 
		final Matrix m = new Matrix();
		final int PADDING = 6;

6
CodeRank

Related Path computeBounds Questions & Answers:

computeBounds Method Overview
Compute the bounds of the control points of the path, and write the answer into bounds.
See Code Examples for other Android Path Methods: