
Sub MouseDemo ( )
	Dim CurrentX As Integer
	Dim CurrentY As Integer
	Dim MouseButtons As Integer
	Dim CanExit As Integer
	Dim As String A,B,C
	
	CanExit = 1
 
	Dim As Double V = 0.0
	Dim As VertexType Digital

	Dim As String Card
	Card = EMPTY
 
	Dim As String CI
	CI = EMPTY
 
	Dim As FB.Image Ptr Buffer, CardBuffer
 
	Do While CanExit <> 0
		
		Cls

		CI = Inkey ( )
		
		Sleep 1, 1
		
		Select Case CI
		Case ESC, MouseCloseEvent
			Exit Do
		End Select
		
		GetMouse CurrentX, CurrentY,, MouseButtons
		If CurrentX < 0 Then
			Print "Mouse is out of context."
		Else
			If MouseButtons And LEFTBUTTON Then A="L"
			If MouseButtons And MIDDLEBUTTON Then B="M"
			If MouseButtons And RIGHTBUTTON Then C="R"
			Locate 1, 1
			Print Using "Mouse Offset: ###:### Buttons: &&&"; CurrentX; CurrentY;A;B;C
			A=EMPTY:B=EMPTY:C=EMPTY 
			
			V = VectorToDecimal ( 320 - CurrentX, 240 - CurrentY )

			Locate 3, 1
			Print V;

			rem :: CompassDigital.XYZ ( Vec. ) ( V, Digital.XYZ ( Vec.X ), Digital.XYZ ( Vec.Y ) )
			
			Line ( 320, 240 ) - ( Digital.XYZ ( Vec.X ), Digital.XYZ ( Vec.Y ) ), RGBA ( 255, 164, 64, 128 )

			Line ( 320, 240 ) - ( CurrentX, CurrentY ), RGBA ( 240, 196, 64, 128 )
			
			Card = Cardinals ( Fix ( CompassRose ( V ) ) )
			
			Buffer = Text2Buffer ( Card, RGBA ( 255, 255, 255, 196 ) )
			
			CardBuffer = ImageCreate (  Len ( Card ) * 8 * 3, 8 * 5 , RGBA ( 0, 0, 0, 0 ), 32 )
			
			Gfx_Buffer_Stretch_Aspect ( Buffer, CardBuffer, "height" )
			
			ImageDestroy ( Buffer )
			
			Put ( Digital.XYZ ( Vec.X ) - CardBuffer -> Width \ 2, Digital.XYZ ( Vec.Y ) - CardBuffer -> Height \ 2 ), CardBuffer, Alpha
			
			ImageDestroy ( CardBuffer )
									
		End If
		
		Flip
		
	Loop

End Sub
