Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Canvas1 As Canvas
Private BoxWidth, BoxHeight As Float
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
BoxWidth = Canvas1.Width / 32
BoxHeight = Canvas1.Height / 8
End Sub
Sub Canvas1_MouseDragged (EventData As MouseEvent)
Dim xy() As Int = ScreenPointToGridPoint(EventData.X, EventData.Y)
Canvas1.DrawRect(xy(0) * BoxWidth, xy(1) * BoxHeight, BoxWidth, BoxHeight, fx.Colors.Red, True, 0)
End Sub
Sub ScreenPointToGridPoint (x As Float, y As Float) As Int()
Return Array As Int(x / BoxWidth, y / BoxHeight)
End Sub