#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private img1 As ImageView
Private vpW, vpH As Float
Private xui As XUI
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
vpW = MainForm.RootPane.Width
vpH = MainForm.RootPane.Height
img1.Initialize("")
MainForm.RootPane.AddNode(img1,vpW*0.4,vpH*0.4,vpW*0.2, vpH*0.2)
CSSUtils.SetBackgroundColor(MainForm.RootPane, fx.Colors.Yellow)
For i = 0 To 75
img1.SetImage(drawdiamond(i,vpW*0.2,vpH*0.2,xui.Color_Cyan))
Sleep(25)
Next
For i = 75 To 0 Step -1
img1.SetImage(drawdiamond(i,vpW*0.2,vpH*0.2,xui.Color_Cyan))
Sleep(25)
Next
End Sub
Sub drawdiamond(percent As Int, width As Float, height As Float, color As Int) As B4XBitmap
Dim cnv As B4XCanvas
Dim myimage As B4XView = xui.CreatePanel("")
myimage.SetLayoutAnimated(0,0,0,width,height)
cnv.Initialize(myimage)
Dim path As B4XPath
path.Initialize(width/2,0)
path.LineTo(width,height/2)
path.LineTo(width/2,height)
path.LineTo(0,height/2)
path.LineTo(width/2,0)
cnv.DrawPath(path,color,True,1)
cnv.ClipPath(path)
Dim linheight As Float = height/100 '100 lines
For i = 0 To percent-1
cnv.DrawLine(0,i*linheight,width,(i*linheight)+linheight,xui.Color_ARGB(255,255,255,255),2)
Next
cnv.RemoveClip
Dim bmp As B4XBitmap = cnv.CreateBitmap
cnv.Release
Return bmp
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub