// Creating the bitmap for trails.
trailBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ALPHA_8);
...
// Setup paint for trails.
trailPaint.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(new float[] {
0, 0, 0, 0, (color >> 16) & 0xFF,
0, 0, 0, 0, (color >> 8) & 0xFF,
0, 0, 0, 0, color & 0xFF,
0, 0, 0, 1, 0
})));
...
// onDraw
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (trailBitmap != null) {
canvas.drawBitmap(trailBitmap, 0, 0, trailPaint);
}
}