Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw pattern on canvas on finger dragging

My Android application allows user to open an image, create marks at the specific areas (a visual clue) for which they can separately add notes and exchange within their team.

E.g. To finalize on a construction plan the app allows to open the proposed plan as bitmap, where the management could suggest the modification by marking on the specific sections and add respective notes.

The requirement is, user should get a choice to pick a pattern to be drawn on his finger move.

What are the options Android provide to draw a pattern?

For your reference just look this following image. enter image description here

I want to draw one of the above pattern on finger touch.

like image 250
Rohan Patel Avatar asked Jul 24 '13 07:07

Rohan Patel


1 Answers

With this code you can draw with finger in canvas.

Then add you must add shader to your Paint object to draw patterns like yours.

mPatternBitmap = BitmapFactory.decodeResource(getResources(), pPatternId);
mBitmapShader = new BitmapShader(mPatternBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
mPaint.setShader(mBitmapShader);

Where pPatternId is your patterns image id from res.

like image 182
Ara Badalyan Avatar answered Nov 01 '22 03:11

Ara Badalyan