home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Illuminati2164421062009.psc / BonusFxMod.bas < prev    next >
BASIC Source File  |  2009-10-06  |  1KB  |  30 lines

  1. Attribute VB_Name = "modBonusFx"
  2.  
  3. '   A BONUS SUB-ROUTINE USING LINEAR INTERPOLATION :)
  4.  
  5.  
  6. Sub LinearInterpolation(ByVal FromX As Long, ByVal FromY As Long, ByVal ToX As Long, ByVal ToY As Long, ByVal t As Single, ByRef ReturnX As Long, ByRef ReturnY As Long)
  7.     'this subroutine calculates the interpolated value
  8.     't always ranges from 0 to 1
  9.     '-------------------------------------------------
  10.     Dim DiffX As Long, DiffY As Long
  11.     DiffX = ToX - FromX
  12.     DiffY = ToY - FromY
  13.     ReturnX = FromX + (DiffX * t)
  14.     ReturnY = FromY + (DiffY * t)
  15. End Sub
  16. Sub FxUsage()
  17.     Dim i As Integer
  18.     Dim dt As Single
  19.     Dim StartX As Long, StartY As Long, EndX As Long, EndY As Long
  20.     Dim PlotX As Long, PlotY As Long
  21.     StartX = 10: StartY = 100
  22.     EndX = 100: EndY = 50
  23.     For i = 0 To 100 Step 5
  24.         dt = i / 100
  25.         LinearInterpolation StartX, StartY, EndX, EndY, dt, PlotX, PlotY
  26.         frmMain.pic.PSet (PlotX, PlotY), vbWhite
  27.     Next i
  28. End Sub
  29.     
  30.