Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private lblInfo As Label
Private collist As List
Private txtlist As List
Private destcol(4),actcol(4), white(4) As Int
Private tmr,tmrfont As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
tmr.Initialize("ColChange",20)
tmrfont.Initialize("FontChange",10)
collist.Initialize
collist.Add(Colors.RGB(100,200,220))
collist.Add(Colors.RGB(180,52,72))
collist.Add(Colors.RGB(135,160,220))
collist.Add(Colors.RGB(205,220,240))
collist.Add(Colors.RGB(200,180,160))
txtlist.Initialize
txtlist.Add("This is a long testtext to check the labels dimensions...")
txtlist.Add("The quick brown fox jumps over the lazy dog...")
txtlist.Add("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
lblInfo.Typeface = Typeface.LoadFromAssets("roboto-light.ttf")
lblInfo.TextColor = Colors.white
lblInfo.TextSize = 30
lblInfo.Text = "This is a long testtext to check the labels dimensions..."
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GetARGB(Color As Int) As Int()
Dim res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8)
res(3) = Bit.AND(Color, 0xff)
Return res
End Sub
Sub lblInfo_Click
actcol(1)=destcol(1)
actcol(2)=destcol(2)
actcol(2)=destcol(3)
Dim random As Int = Rnd(0,collist.Size)
destcol = GetARGB(collist.Get(random))
destcol(0)=255
lblInfo.Color = Colors.ARGB(255,destcol(1),destcol(2),destcol(3))
lblInfo.TextColor = Colors.white
white = GetARGB(Colors.White)
white(0) = 255
Dim random As Int = Rnd(0,txtlist.Size)
lblInfo.Text = txtlist.Get(random)
tmr.Enabled = True
'lblInfo.TextColor
End Sub
Sub FontChange_Tick
If white(0) > 0 Then
white(0) = white(0)-1
End If
lblInfo.TextColor = Colors.ARGB(white(0),white(1),white(2),white(3))
If white(0) = 0 Then
tmrfont.Enabled = False
Log("Font opaque... Set new Text and start again...")
End If
End Sub
Sub ColChange_Tick
Dim r,g,b As Boolean = False
If actcol(1) > destcol(1) Then
' Decrease R
actcol(1) = actcol(1)-1
Else If actcol(1) < destcol(1) Then
' Increase R
actcol(1) = actcol(1)+1
Else If actcol(1) = destcol(1) Then
' R reached destination
r = True
End If
If actcol(2) > destcol(2) Then
' Decrease G
actcol(2) = actcol(2)-1
Else If actcol(2) < destcol(2) Then
' Increase G
actcol(2) = actcol(2)+1
Else If actcol(2) = destcol(2) Then
' G reached destination
g = True
End If
If actcol(3) > destcol(3) Then
' Decrease B
actcol(3) = actcol(3)-1
Else If actcol(3) < destcol(3) Then
' Increase B
actcol(3) = actcol(3)+1
Else If actcol(3) = destcol(3) Then
' B reached destination
b = True
End If
lblInfo.Color = Colors.ARGB(255,actcol(1),actcol(2),actcol(3))
If r Then
If g Then
If b Then
Log("Destinationcolor reached")
tmr.Enabled = False
tmrfont.Enabled = True
Else
'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
End If
Else
'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
End If
Else
'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
End If
End Sub