Code example for Path

Methods: computeBoundstransform

0
     * {@inheritDoc}  
     */ 
    public void translate(float x, float y) {
        Matrix mat = new Matrix();
        mat.postTranslate(x, y);
        mPath.transform(mat);
        update(); 
    } 
     
    /** 
     * Sets the next start point (x, y). 
     * @param x The x-coordinate of next start point 
     * @param y The y-coordinate of next start point 
     */ 
    public void moveTo(float x, float y) {
        mPath.moveTo(x, y);
        update(); 
    } 
 
    /** 
     * Adds a line from the last point to the specified point (x, y). 
     * @param x The x-coordinate of specified point 
     * @param y The y-coordinate of specified point 
     */ 
    public void lineTo(float x, float y) {
        mPath.lineTo(x, y);
        update(); 
    } 
 
    /** 
     * Adds a copy of specified path. 
     * @param shape The specified path 
     */ 
    public void append(Shape shape) {
        mPath.addPath(shape.getPath());
        update(); 
    } 
 
    /** 
     * 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 
     */ 
    public float getX() { 
        return mRegion.getBounds().left;
    } 
 
    /** 
     * Returns y-coordinate of shape bound. 
     * @return y-coordinate of shape bound 
     */ 
    public float getY() { 
        return mRegion.getBounds().top;
    } 
 
    /** 
     * Returns width of shape bound. 
     * @return The width of shape bound 
     */ 
    public float getWidth() { 
        return mRegion.getBounds().width();
    } 
 
    /** 
     * Returns height of shape bound. 
     * @return The height of shape bound 
     */ 
    public float getHeight() { 
        return mRegion.getBounds().height();
    } 
     
    /** 
     * Updates the internal data required to draw. 
     */ 
    private void update() { 
        RectF rect = new RectF();
        mPath.computeBounds(rect, false);
        mRegion = new Region((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom);
        mRegion.setPath(mPath, mRegion);
    } 
 
    /** 
Stop searching for code, let great code find you!  Add Codota to your java IDE