rubber banding

wolfgang

Member
Licensed User
Hi,
maybe usefull for some GPS apps and track drawings:
B4X:
Sub Globals
   'Declare the global variables here.
   Dim Type(sx,sy,ex,ey)m As Int16
   draw = ""
End Sub

Sub App_Start
   Form1.Show
   Form1.ForeLayer = true
End Sub


Sub Form1_MouseDown (x,y)
   m.sx = x
   m.sy = y
   Form1.Circle(x,y,5,cRed,F)
   draw = true
End Sub

Sub Form1_MouseMove (x,y)
                         If draw = true Then
      m.ex = x
      m.ey = y
      Else
         m.ex = m.sx
         m.ey = m.sy
   End If
   Form1.FErase(0,0,Form1.Width,Form1.Height)
   Form1.FLine(m.sx,m.sy,m.ex,m.ey,cGreen)
End Sub

Sub Form1_MouseUp (x,y)
   Form1.Line(m.sx,m.sy,x,y,cGreen)
   Form1.Circle(m.sx,m.sy,5,cRed,F)
   Form1.Circle(m.ex,m.ey,5,cRed,F)
   draw = false
End Sub
 

wolfgang

Member
Licensed User
Hi,
rubber banding improved. It’s faster and smoother now, with an additional feature. Play with timer1.interval to get the best performance. Could be useful for GPS and way point navigation.
 

Attachments

Last edited:

VoDB

Member
Licensed User
Hallo wolfgang,
pretty nice application and a good idea. Please allow me some annotation: The timer is not really necessary. You can write something like this:
B4X:
Sub Form1_MouseMove(x,y)
   If draw = False Then Return
...
Then the MouseMove event should include the timer code. In the headdist procedure, you can reduce the If-intersections from 8 to 4, if you use the sinus and not the arc tangent.
Maybe, it's a better Idea, when you not wipe out the Position Information?

Cheerio
VoDB
 
Top