Android Path - top ranked examples from Open Source projects

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

This code example shows how to use the following methods: close, lineTo, moveTo
            float left, top, right, bottom;
            left = MathUtils.random(getWidth() - MIN_SIZE);
            top = MathUtils.random(getHeight() - MIN_SIZE);
            right = left + MathUtils.random(getWidth() - left);
            bottom = top + MathUtils.random(getHeight() - top);
            Path path = new Path();
            path.moveTo(left, top);
            path.lineTo(right, top);
            path.lineTo(right, bottom);
            path.lineTo(left, bottom);
            path.close();
            return path;
        } 
 
        private int getRandomColor() { 
            int red = MathUtils.random(255);
            int green = MathUtils.random(255);
            int blue = MathUtils.random(255);
            return 0xff000000 | red << 16 | green << 8 | blue;
        } 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, lineTo
		this.leftArrow = leftArrow;
		configureDrawable(); 
	} 
 
	private void configureDrawable() { 
		path = new Path();
 
		if (leftArrow) {
			path.moveTo(0.0f, 1.0f);
			path.lineTo(1.0f, 2.0f);
			path.lineTo(1.0f, 0.0f);
			path.close();
		} else { 
			path.lineTo(1.0f, 1.0f);
			path.lineTo(0.0f, 2.0f);
			path.lineTo(0.0f, 0.0f);
			path.close();
		} 
 
		setWillNotDraw(false);

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: cubicTo, moveTo
        final PathsView view = new PathsView(this);
        setContentView(view);
    } 
 
    private static Path makePath() {
        Path path = new Path();
        buildPath(path);
        return path;
    } 
 
    private static void buildPath(Path path) {
        path.moveTo(0.0f, 0.0f);
        path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
        path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
        path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
    } 
 
    private static Path makeLargePath() {
        Path path = new Path();
        buildLargePath(path);
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, lineTo, moveTo
        paint.setColor(BG_COLOR);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
 
        paint.setColor(FILTER_COLOR);
        Path path = new Path();
        path.moveTo(getWidth() * (0.5f - 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * end / max), getHeight());
        path.lineTo(getWidth() * (0.5f - 0.5f * end / max), getHeight());
        path.close();
        canvas.drawPath(path, paint);
 
        paint.setColor(TEXT_COLOR);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setTextSize(16);
        canvas.drawText(Integer.toString(end), getWidth() / 2, getHeight() / 2, paint);
    } 
 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: lineTo, moveTo
 
  private static Path getTrianglePath(Point p1, int width) {
    Point p2 = new Point(p1.x + width, p1.y);
    Point p3 = new Point(p1.x, p1.y + width);
 
    Path path = new Path();
    path.moveTo(p1.x, p1.y);
    path.lineTo(p2.x, p2.y);
    path.lineTo(p3.x, p3.y);
 
    return path;
  } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, cubicTo, lineTo, moveTo, reset
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, lineTo, moveTo
            float left, top, right, bottom;
            left = MathUtils.random(getWidth() - MIN_SIZE);
            top = MathUtils.random(getHeight() - MIN_SIZE);
            right = left + MathUtils.random(getWidth() - left);
            bottom = top + MathUtils.random(getHeight() - top);
            Path path = new Path();
            path.moveTo(left, top);
            path.lineTo(right, top);
            path.lineTo(right, bottom);
            path.lineTo(left, bottom);
            path.close();
            return path;
        } 
 
        private int getRandomColor() { 
            int red = MathUtils.random(255);
            int green = MathUtils.random(255);
            int blue = MathUtils.random(255);
            return 0xff000000 | red << 16 | green << 8 | blue;
        } 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, lineTo, moveTo
	} 
 
	private void createShineArea() { 
		int width = getWidth();
		int height = (int) (0.9 * getHeight());
		path = new Path();
		path.moveTo(0, 0);
		path.lineTo(width, 0);
		path.lineTo(width, height);
		path.close();
		paint.setShader(new LinearGradient(0, 0, 0, height, 0x55ffffff,
				0x10ffffff, Shader.TileMode.CLAMP));
	} 
 
	@Override 
	protected void dispatchDraw(Canvas canvas) {
		if (path == null) {
			createShineArea(); 
		} 
		// Draw the shine behind the children. 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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);
    } 
     
    /** 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Path Questions & Answers:

See Code Examples for Android Path Methods: