I found this little code example to make a finger drawing:
http://marakana.com/tutorials/android/2d-graphics-example.html
Here are some of the relevant code:
List<Point> points = new ArrayList<Point>(); @Override public void onDraw(Canvas canvas) { for (Point point : points) { canvas.drawCircle(point.x, point.y, 5, paint); } } public boolean onTouch(View view, MotionEvent event) { Point point = new Point(); point.x = event.getX(); point.y = event.getY(); points.add(point); invalidate(); Log.d(TAG, "point: " + point); return true; }
I looked at it and saw that they add points to the ArrayList, and then loop through the ArrayList, it does not look like this is a very optimized approach to this. Is there a better approach or is it a good approach?
After testing on my Samsung GS3, I painted the entire screen with a circle size of 20, and the closer it got to a full color image, the slower it took to draw, and then the circles became spaced.
source share