Hi all,
I had some problems with Canvas on my project, so decided to reproduce it in a small code to know what is the problem.
Can someone explain this ?
On this code:
Many thanks
I had some problems with Canvas on my project, so decided to reproduce it in a small code to know what is the problem.
Can someone explain this ?
On this code:
- If I uncomment all pnl.Invalidate I see the first left green line, so even if I do not Invalidate the panel
- If I uncomment the pnl.Invalidate (OPTION 1) all was ok and the full panel is invalidated
- If I uncomment the pnl.Invalidate2 or pnl.Invalidate3 (OPTION 2, OPTION 3) I always see the first green line on the left, then it only invalidates the whole rectangle, but this only works if I set targetSdkVersion 13 on the manifest, with targetSdkVersion 14+ it invalidate the full panel not just the rectangle
Many thanks
Code:
Sub Process_Globals
Private cols() As Int = Array As Int(Colors.Green, Colors.Magenta, Colors.Red, Colors.Cyan, Colors.Blue, Colors.White)
End Sub
Sub Globals
Private pnl As Panel
Private cvs As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("Layout1")
pnl.Initialize("pnl")
Activity.AddView(pnl, 0, 0, 100%x, 100%y)
cvs.Initialize(pnl)
cvs.AntiAlias = True
cvs.DrawColor(Colors.Black)
Activity.Invalidate
DoTest
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub DoTest
Dim x As Float = 0
Do While True
Dim t1 As Long = DateTime.Now
For Each c As Int In cols
For x = 0 To 100%x Step 1dip
cvs.DrawLine(x, 0, x, 100%y, c, 1dip)
' pnl.Invalidate ' OPTION 1 (Invalidate the full panel)
' Dim Rect1 As Rect
' Rect1.Initialize(100dip, 100dip, 300dip, 300dip)
' pnl.Invalidate2(Rect1) ' OPTION 2 (Invalidate just a rectangle by rectangle)
pnl.Invalidate3(100dip, 100dip, 300dip, 300dip) ' OPTION 3 (Invalidate just a rectangle by coordinates)
If x Mod 10 = 0 Then Sleep(0)
' Sleep(100)
Next
Next
t1 = DateTime.Now - t1
Log("Required " & t1 & " Milliseconds")
Loop
End Sub
Last edited: