[bb] Simple Transition Algorithm by Techlord [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Simple Transition Algorithm
Author : Techlord
Posted : 1+ years ago

Description : Nifty algo that can be used to increment gradually from one value to another.

Code :
Code (blitzbasic) Select
;transition algo
from_n=from_n+Sgn(to_n-from_n);version 1
from_n#=from_n#+(Sgn(to_n#-from_n#)*inc_value#);verson 2

;version 1 demo
from_n=1000
to_n=100
Repeat
from_n=from_n+Sgn(to_n-from_n)
Print from_n
Until from_n=to_n
WaitKey
End

;version 2 demo
from_n#=1000
to_n#=100
inc_value#=5.

Repeat
from_n#=from_n#+(Sgn(to_n#-from_n#)*inc_value#)
Print from_n#
Until from_n#=to_n#

WaitKey
End


Comments : none...