I want to know how can I make a line appear slowly from one end to another end,to make user feel that someone is drawing that line.
Printable View
I want to know how can I make a line appear slowly from one end to another end,to make user feel that someone is drawing that line.
u could just slowly change the length of the line in small increments.
Try setting a timer..... and make sure a global const is in place (mcIntervals), to execute this code. Also have the X1, Y1, X2, Y2 values you need for drawing a line: (in X1, X2, Y1, Y2)
This timer event draws a line (well in this example 1 - 100%) of the way to the finish point, at an interval of the timer. If you set the mcIntervals constant to 50 then it would take half as long and wouldn't look as good.Code:'after line is drawn set timer1's enabled property to true
'start timer1 with enabled=false
Dim unsInt as Integer
Const mcIntervals = 100
'---> set x1, x2, y1, y2 here and enable timer1...
Private Sub Timer1_Timer()
Dim TempX2, TempY2
unsInt = unsInt + 1
TempX2 = ((x1 - x2) / mcIntervals) * unsInt
TempX2 = X1 + TempX2
TempY2 = ((y1 - y2) / mcIntervals) * unsInt
TempY2 = y1 + Tempy2
Me.Cls
Me.Line (X1, TempX2)-(Y1, TempY2)
If unsInt = mcIntervals then
unsInt = 0
Timer1.Enabled = False
End If
End Sub
I noticed a few odd bits in the code when I tried it myself; here is an updated version:
Code:'after line is drawn set timer1's enabled property to true
'start timer1 with enabled=false
Dim unsInt As Integer
Const mcIntervals = 100
'---> set x1, x2, y1, y2 here and enable timer1...
Private Sub Timer1_Timer()
Dim TempX2, TempY2
unsInt = unsInt + 1
TempX2 = ((X1 - X2) / mcIntervals) * unsInt
TempX2 = -TempX2
TempX2 = Int(X1 + TempX2)
TempY2 = ((Y1 - Y2) / mcIntervals) * unsInt
TempY2 = -TempY2
TempY2 = Int(Y1 + TempY2)
Me.Cls
Me.Line (X1, Y1)-(TempX2, TempY2)
If unsInt = mcIntervals Then
unsInt = 0
Timer1.Enabled = False
End If
End Sub