Sub Globals
Private cvsActivity As Canvas
Private Panel1 As Panel
Private w, h As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout") 'has Panel1 and button1
cvsActivity.Initialize (Panel1)
w=Panel1.Width/2 'to bring the plot more inward
h=Panel1.Height/2 'to bring the plot more inward
End Sub
Sub Button1_Click
Dim Rect1 As Rect
Rect1.Initialize(0, 0, 100%x, 100%y)
cvsActivity.DrawRect(Rect1, Colors.black, True, 1dip)
Panel1.Invalidate
Private a As Double
Private x, y,r,s,n As Int
Private lastx, lasty As Int
r=Rnd(275, 351)
s=Rnd(100, 126)
n=Rnd(10, 21)
For a = 0 To 2 * cPI Step 0.01
x = r * Cos(a) + s * Cos(n * a) + w
y = r * Sin(a) + s * Sin(n * a) + h
If a = 0 Then
lastx = x
lasty = y
End If
If a <= 3 Then
cvsActivity.DrawLine(lastx, lasty, x, y, Colors.Yellow, 2dip)
Else if a>3 And a < = 10 Then
cvsActivity.DrawLine(lastx, lasty, x, y, Colors.Red, 2dip)
Else
cvsActivity.DrawLine(lastx, lasty, x, y, Colors.cyan, 2dip)
End If
Panel1.Invalidate
Sleep(0) 'change to suit
lastx = x
lasty = y
Next
Log($"r: ${r}, s: ${s}, n: ${n},"$)
Log("done")
End Sub