So I have a PNG file which I am using as a custom brush in my app. As a motion event takes place, I keep redrawing it to give a brush effect. But if I drag too fast I miss pixels and some brushes look really bad - like the images are just drawn over each other.
Is there any way I can draw it in a drawpath
mode instead?
The code below is my onDraw
method. The mbitmapBrush
variable has the PNG image file, and pos.a
and pos.b
are the current motion event 'x' and 'y' coordinates.
@Override
protected void onDraw(Canvas canvas) {
Paint paint=mPaint;
canvas.drawColor(0xFFAAAAAA);
mCM.set(new float[]{1f, 1f, 1f, 0f, 1f,
0f, 1f, 3f, 0f, 4f,
1f, 4f, 1f, 1f, 0f,
1f, 0f, 0f, 1f, 0f });
ColorMatrixColorFilter cm3=new ColorMatrixColorFilter(mCM);
paint.setColorFilter(cm3);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
for (Vector2 pos : mPositions) {
canvas.drawBitmap(mBitmapBrush, pos.a, pos.b, paint);
//canvas.drawCircle(pos.a, pos.b, 7, mPaint);
}
//canvas.drawBitmap(mBitmapBrush, clickX, clickY, null);
//canvas.drawPath(mPath, mPaint);
invalidate();
}