1

Hello i have created a canvas that i stick into an imageview of the size of my layout ! In this canvas i create lines that the end of the first is the begging of the second ! My problem is that when the final line is being created how will i be able to erase parts of this line ?

    final Bitmap bmp = Bitmap.createBitmap(layout.getWidth(),layout.getHeight(),  Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bmp);
    final Paint textPaint = new Paint();
    textPaint.setColor(Color.RED);
    textPaint.setStrokeWidth(5);
    canvas.drawLine(startx, starty, endx, endy, textPaint);
    mView.setImageBitmap(bmp);

thank you :)

braX
  • 11,506
  • 5
  • 20
  • 33
kasf
  • 113
  • 1
  • 2
  • 11
  • Just paint over the area you want to erase :) – JiTHiN Jul 29 '14 at 11:58
  • @rIHaN JiTHiN paint over with what ? on the background there is an other image so i cant draw another line on top of my line to make it invisible ? if i draw a line that is transparent will it work ? and will the background picture appear too ? – kasf Jul 29 '14 at 12:02
  • Hmm.. in that case refer this [SO question](http://stackoverflow.com/questions/18130341/drawing-holes-in-a-canvas) – JiTHiN Jul 29 '14 at 12:17
  • You only want the last line to show, is that right? So you paint transparent lines until you get to draw the last line. – joao2fast4u Jul 29 '14 at 13:02
  • @joao2fast4u no i want to show all the line and the slowly to take it away – kasf Jul 29 '14 at 13:39
  • You want to erase the lines after drawing them? – joao2fast4u Jul 29 '14 at 13:45
  • @joao2fast4u no once the whole line has been made (which is made from many small lines ) i want to erase the small lines one by one until the is no line ! – kasf Jul 29 '14 at 14:37
  • ok, starting by the last line or by the first? – joao2fast4u Jul 29 '14 at 14:59
  • @joao2fast4u by the last line ! basically i have a big line and i want slowly to vanish it :) – kasf Jul 29 '14 at 17:34
  • 1
    I think you will have to clear the canvas and draw everything over again and again, with the disappearing line having progressively lower alpha. Possible performance improvement (not sure): If your background is always the same, create two views on top of each other, so at least the background doesn't have to be continuously redrawn. – Tenfour04 Jul 30 '14 at 17:33
  • @Tenfour04 the solution you offeres is actually REALLY REALLY good ! and i think it will have a stable performance ! – kasf Jul 30 '14 at 17:36
  • I haven't tested that and I don't know much about the Canvas backend...like whether the background really isn't getting redrawn by the GPU just because it's in a separate canvas. But good luck, hopefully it works. – Tenfour04 Jul 30 '14 at 17:37

0 Answers0