Android Question Canvas - refresh or delete all image

ivanomonti

Well-Known Member
Licensed User
IT: come posso ripulire un canvas do un pannello eliminando l'immagine precedente!!!
EN: how do I clear a canvas panel eliminating the previous picture !!!

Screenshot_2015-01-08-10-25-21.png
 

sorex

Expert
Licensed User
sure there is.

use either that blue-ish color that is the background of that picture or use colors.transparent.
 

erosmax

Well-Known Member
Licensed User
Potresti usare la libreria Gestures ;)


B4X:
Private Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean 'ignore
    Dim p As Point
    Select Action
        Case g.ACTION_DOWN, g.ACTION_POINTER_DOWN
            'New Point is assigned to the new touch
            p.Id = PointerID
            p.Color = Colors.Transparent
            TouchMap.Put(PointerID, p)
        Case g.ACTION_POINTER_UP
            TouchMap.Remove(PointerID)
        Case g.ACTION_UP
            'This is the end of this gesture
            TouchMap.Clear
    End Select
    Dim px, py As Int
    For i = 0 To TouchMap.Size - 1
        p = TouchMap.GetValueAt(i)
        px = g.GetX(p.id)
        py = g.GetY(p.id)
        If p.prevX > 0 AND p.prevY > 0 Then
            Canvas.DrawLine(p.prevX, p.prevY, px, py, p.Color, 10dip)
        End If
        p.prevX = px
        p.prevY = py
    Next
    pnlCoprente.Invalidate
    Return True
End Sub
 
Top