Hi, I'm learning how to use canvas object.
I paint a line, text or anything, when I release the click and touch to start drawing again my last draw is deleted.
I have a line of code canvas1.ClearRect(canvas1.TargetRect), but If I delete it, the draw is repeated on every moved of mouse.
How can I continue drawing without lost the old draw and not show again the same draw.
I want to do a basic paint tool, first on B4J to learn and then write it on b4a.
I see a nice library called CanvasView, but not have all I want.
I paint a line, text or anything, when I release the click and touch to start drawing again my last draw is deleted.
I have a line of code canvas1.ClearRect(canvas1.TargetRect), but If I delete it, the draw is repeated on every moved of mouse.
How can I continue drawing without lost the old draw and not show again the same draw.
I want to do a basic paint tool, first on B4J to learn and then write it on b4a.
I see a nice library called CanvasView, but not have all I want.
B4X:
Sub Pane1_Touch (Action As Int, X As Float, Y As Float)
'Action 0 Click
'Action 1 Soltar click
'Action 2 Click mantenido
'Action 100 mover mouse encima
If Action=0 Then
posX_inicio=X
posY_inicio=Y
else if Action=2 Then
canvas1.ClearRect(canvas1.TargetRect)
'canvas1.DrawLine(x, y,posX_inicio , posY_inicio, xui.Color_Black, 2)
canvas1.DrawText("This is a test", X,Y, font1, xui.Color_Black,"LEFT")
' canvas1.DrawCircle(X, Y, 10+posX_inicio, xui.Color_Black, False, 2)
Else if Action=1 Then
' canvas1.DrawLine(x, y,posX_inicio , posY_inicio, xui.Color_BlAck, 2)
' Dim out As OutputStream
' out = File.OpenOutput(File.DirApp, "test.jpg", False)
' Pane1.Snapshot(imagen1.WriteToStream(out, 100, "JPG"))
'
' Dim imagen2 As B4XBitmap
' imagen2 = File.OpenInput(File.DirApp, "test.jpg")
' canvas1.DrawBitmap(imagen2, canvas1.TargetRect)
End If
End Sub