Reputation: 742
I want to achieve an effect like this one:
Anybody has an idea on how to draw such a line on a Canvas?
Upvotes: 4
Views: 1169
Reputation: 742
getting a little closer:
chalkPaint = new Paint();
chalkPaint.setStyle(Style.STROKE);
chalkPaint.setStrokeWidth(12);
Bitmap chalkShader = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.chalk_texture)).getBitmap();
chalkPaint.setShader(new BitmapShader(chalkShader, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT));
this paints a texture with a chalk effect:
now I "just" need the irregular border... still trying...
Upvotes: 2
Reputation: 26547
This is probably harder to do than you think.
Drawing a line like this is mainly based on randomness. For example, between "M" and "N" in your picture, I think there are not one but four successive small lines of different brush sizes (chosen randomly in a small interval). Look closer, and you will see them.
The coordinates of these four small lines are also randomly adjusted (by a very small amount) to avoid having a straight line once put together.
There may also be a random number of small lines between two squares (I think there are more than four small lines between "R" and "X").
You may try to search for a library which already do the job, I don't know if there is one but it's not impossible.
Upvotes: 0