home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / SCRNSAVE / BACKGRND.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1993-04-16  |  41.4 KB  |  1,183 lines

  1. VERSION 2.00
  2. Begin Form BackGround 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ControlBox      =   0   'False
  6.    Height          =   2976
  7.    Icon            =   BACKGRND.FRX:0000
  8.    Left            =   864
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   213
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   478
  13.    Top             =   1260
  14.    Width           =   5832
  15.    Begin Timer Tick 
  16.       Interval        =   50
  17.       Left            =   10
  18.       Top             =   10
  19.    End
  20. ' BackGround -- this form expands to fill the whole
  21. '   screen and is used as the back drop for all the
  22. '   drawing
  23. Option Explicit
  24. ' variables declared here
  25. Dim lastX, lastY            ' Last position of the moves
  26. Dim LastTime As Long
  27. Dim CurrentTime As Long
  28. Dim LinkTime As Long
  29. Dim PlotType As Integer
  30. Dim PlotInit As Integer
  31. Dim RepeatIndex As Integer
  32. Dim Pointer As Integer
  33. Dim Mirror As Integer
  34. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  35. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  36. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  37. Dim l As Long
  38. Dim m As Long
  39. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  40. Dim TimeInterval As Long
  41. Dim MaxTime As Long
  42. Dim Repeats As Integer
  43. Dim i As Integer
  44. Dim BoxHeight As Integer, BoxWidth As Integer
  45. Dim DC As Integer
  46. Dim Pattern As Long, Locked As Integer
  47. Dim Direction As Integer
  48. 'Allocate Memory
  49. Dim x1a() As Integer
  50. Dim x2a() As Integer
  51. Dim y1a() As Integer
  52. Dim y2a() As Integer
  53. Dim x1da() As Integer
  54. Dim x2da() As Integer
  55. Dim y1da() As Integer
  56. Dim y2da() As Integer
  57. Dim x1sa() As Single
  58. Dim x2sa() As Single
  59. Dim y1sa() As Single
  60. Dim y2sa() As Single
  61. Dim vx1sa() As Single
  62. Dim vx2sa() As Single
  63. Dim vy1sa() As Single
  64. Dim vy2sa() As Single
  65. Dim ax1sa() As Single
  66. Dim ax2sa() As Single
  67. Dim ay1sa() As Single
  68. Dim ay2sa() As Single
  69. Dim Colors() As Long
  70. Dim DataPts() As Integer
  71. Dim MaxPlotType As Integer
  72. Sub Circles ()
  73.   ' have a single elipse trace across the
  74.   ' screen with multiple previous copies following
  75.   ' it
  76.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  77.   Dim xRadius As Integer, yRadius As Integer
  78.   ' if first time then initialize
  79.   If PlotInit = False Then
  80.     PlotInit = True
  81.     Cls
  82.     Forecolor = QBColor(15)
  83.     'Set array size and clear the elements
  84.     ReDim x1a(MaxLines) As Integer
  85.     ReDim x2a(MaxLines) As Integer
  86.     ReDim y1a(MaxLines) As Integer
  87.     ReDim y2a(MaxLines) As Integer
  88.     Pointer = 1     ' start with array element 1
  89.     ' set index to count number of times to repeat color
  90.     '   to past maxvalue so that it will be recalculated
  91.     RepeatIndex = MaxLines + 1
  92.     'determine initial position of line
  93.     x1 = Rnd * ScaleWidth
  94.     x2 = Rnd * ScaleWidth
  95.     y1 = Rnd * ScaleHeight
  96.     y2 = Rnd * ScaleHeight
  97.     'set initial velocity
  98.     vx1 = 0
  99.     vx2 = 0
  100.     vy1 = 0
  101.     vy2 = 0
  102.     'set initial acceleration
  103.     ax1 = 0
  104.     ax2 = 0
  105.     ay1 = 0
  106.     ay2 = 0
  107.     'find background color
  108.     m = QBColor(0)
  109.     'Calculate velocity limits
  110.     MaxSpeedX = ScaleWidth * 15! / 800
  111.     MaxSpeedY = ScaleWidth * 15! / 600
  112.   Else  ' put run code here
  113.     ' check if time to get a new color
  114.     If RepeatIndex > RepeatCount Then
  115.         ' use rgb function
  116.         i = Rnd * 255: If i > 255 Then i = 255
  117.         j = Rnd * 255: If j > 255 Then j = 255
  118.         k = Rnd * 255: If k > 255 Then k = 255
  119.         l = RGB(i, j, k)
  120.         RepeatIndex = 1
  121.     Else
  122.         RepeatIndex = RepeatIndex + 1
  123.     End If
  124.         'Delete original circle
  125.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  126.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  127.         If xRadius <> 0 Then
  128.             Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  129.         End If
  130.         'Save New Circle
  131.         x1a(Pointer) = x1
  132.         x2a(Pointer) = x2
  133.         y1a(Pointer) = y1
  134.         y2a(Pointer) = y2
  135.         'Draw new Circle
  136.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  137.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  138.         If xRadius <> 0 Then
  139.             Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  140.         End If
  141.         'Move pointer to next item
  142.         Pointer = Pointer + 1
  143.         If Pointer > MaxLines Then
  144.             Pointer = 1
  145.         End If
  146.         'determine new acceleration
  147.         ax1 = Rnd - .5
  148.         ax2 = Rnd - .5
  149.         ay1 = Rnd - .5
  150.         ay2 = Rnd - .5
  151.         'calculate new position
  152.         x1 = x1 + vx1
  153.         x2 = x2 + vx2
  154.         y1 = y1 + vy1
  155.         y2 = y2 + vy2
  156.         'calculate new velocity
  157.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  158.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  159.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  160.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  161.         'check if off screen
  162.         If (x1 > ScaleWidth) Then
  163.             'change direction
  164.             vx1 = -Abs(vx1)
  165.         ElseIf (x1 < 0) Then
  166.             'change direction
  167.             vx1 = Abs(vx1)
  168.         End If
  169.         If (y1 > ScaleHeight) Then
  170.             'change direction
  171.             vy1 = -Abs(vy1)
  172.         ElseIf (y1 < 0) Then
  173.             'change direction
  174.             vy1 = Abs(vy1)
  175.         End If
  176.         If (x2 > ScaleWidth) Then
  177.             'change direction
  178.             vx2 = -Abs(vx2)
  179.         ElseIf (x2 < 0) Then
  180.             'change direction
  181.             vx2 = Abs(vx2)
  182.         End If
  183.         If (y2 > ScaleHeight) Then
  184.             'change direction
  185.             vy2 = -Abs(vy2)
  186.         ElseIf (y2 < 0) Then
  187.             'change direction
  188.             vy2 = Abs(vy2)
  189.         End If
  190.   End If
  191. End Sub
  192. Sub ClearArrays ()
  193.         'clear arrays
  194.         ReDim x1a(0) As Integer
  195.         ReDim x2a(0) As Integer
  196.         ReDim y1a(0) As Integer
  197.         ReDim y2a(0) As Integer
  198.         ReDim x1da(0, 0) As Integer
  199.         ReDim x2da(0, 0) As Integer
  200.         ReDim y1da(0, 0) As Integer
  201.         ReDim y2da(0, 0) As Integer
  202.         ReDim x1sa(0) As Single
  203.         ReDim x2sa(0) As Single
  204.         ReDim y1sa(0) As Single
  205.         ReDim y2sa(0) As Single
  206.         ReDim vx1sa(0) As Single
  207.         ReDim vx2sa(0) As Single
  208.         ReDim vy1sa(0) As Single
  209.         ReDim vy2sa(0) As Single
  210.         ReDim ax1sa(0) As Single
  211.         ReDim ax2sa(0) As Single
  212.         ReDim ay1sa(0) As Single
  213.         ReDim ay2sa(0) As Single
  214.         ReDim Colors(0) As Long
  215. End Sub
  216. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  217.     EndScrnsave                 ' End screen blanking
  218. End Sub
  219. Sub Form_Load ()
  220.     ' stretch to full screen
  221.     Move 0, 0, Screen.Width, Screen.Height
  222.     DrawWidth = 1
  223.     'For i = 1 To 10: l = Rnd: Next i' clear first values from Rnd
  224.     Randomize
  225.     ' Initialize variables now
  226.     MaxPlotType = 12
  227.     PlotType = Rnd * (MaxPlotType + 1)' choose random start place
  228.     'PlotType = 8 ' fixed start place
  229.     If PlotType > MaxPlotType Then PlotType = 0
  230.     PlotInit = False
  231.     TimeInterval = 0
  232.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  233.     HideMouse
  234.     Repeats = 1 ' number of drawings to make before returning
  235. End Sub
  236. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  237.     If IsEmpty(lastX) Or IsEmpty(lastY) Then
  238.         lastX = x
  239.         lastY = y
  240.     End If
  241.     '
  242.     ' Only unblank the screen if the mouse moves quickly
  243.     ' enough (more than 2 pixels at one time.
  244.     '
  245.     If Abs(lastX - x) > 2 Or Abs(lastY - y) > 2 Then
  246.         EndScrnsave             ' End screen blanking
  247.     End If
  248.     lastX = x                   ' Remember last position
  249.     lastY = y
  250. End Sub
  251. Sub Kalied ()
  252.   ' have a line and its mirror images trace across the
  253.   ' screen with multiple previous copies following
  254.   ' it
  255.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  256.   Dim xRadius As Integer, yRadius As Integer
  257.   Dim HighMirror As Integer
  258.   ' if first time then initialize
  259.   If PlotInit = False Then
  260.     PlotInit = True
  261.     Cls
  262.     Forecolor = QBColor(15)
  263.     'select mirroring method
  264.     HighMirror = 3
  265.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  266.     'Set array size and clear the elements
  267.     ReDim x1a(MaxLines) As Integer
  268.     ReDim x2a(MaxLines) As Integer
  269.     ReDim y1a(MaxLines) As Integer
  270.     ReDim y2a(MaxLines) As Integer
  271.     Pointer = 1     ' start with array element 1
  272.     ' set index to count number of times to repeat color
  273.     '   to past maxvalue so that it will be recalculated
  274.     RepeatIndex = MaxLines + 1
  275.     'determine initial position of line
  276.     x1 = Rnd * ScaleWidth
  277.     x2 = Rnd * ScaleWidth
  278.     y1 = Rnd * ScaleHeight
  279.     y2 = Rnd * ScaleHeight
  280.     'set initial velocity
  281.     vx1 = 0
  282.     vx2 = 0
  283.     vy1 = 0
  284.     vy2 = 0
  285.     'set initial acceleration
  286.     ax1 = 0
  287.     ax2 = 0
  288.     ay1 = 0
  289.     ay2 = 0
  290.     'find background color
  291.     m = QBColor(0)
  292.     'Calculate velocity limits
  293.     MaxSpeedX = ScaleWidth * 15! / 800
  294.     MaxSpeedY = ScaleWidth * 15! / 600
  295.   Else  ' put run code here
  296.     ' check if time to get a new color
  297.     If RepeatIndex > RepeatCount Then
  298.         ' use rgb function
  299.         i = Rnd * 255: If i > 255 Then i = 255
  300.         j = Rnd * 255: If j > 255 Then j = 255
  301.         k = Rnd * 255: If k > 255 Then k = 255
  302.         l = RGB(i, j, k)
  303.         RepeatIndex = 1
  304.     Else
  305.         RepeatIndex = RepeatIndex + 1
  306.     End If
  307.         'Delete original Lines
  308.         Select Case Mirror
  309.         Case 1: 'mirror on x and y axis
  310.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  311.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), m
  312.             Line (x1a(Pointer), ScaleHeight - y1a(Pointer))-(x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  313.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  314.         Case 2: 'mirror on Y axis
  315.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  316.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), m
  317.         Case 3: 'mirror around center point
  318.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), m
  319.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), m
  320.         Case Else: Mirror = 1' if invalid value set, then change
  321.         
  322.         End Select
  323.         'Save New Lines
  324.         x1a(Pointer) = x1
  325.         x2a(Pointer) = x2
  326.         y1a(Pointer) = y1
  327.         y2a(Pointer) = y2
  328.         'Draw New Lines
  329.         Select Case Mirror
  330.         Case 1: 'mirror on x and y axis
  331.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  332.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), l
  333.             Line (x1a(Pointer), ScaleHeight - y1a(Pointer))-(x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  334.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  335.         Case 2: 'mirror on Y axis
  336.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  337.             Line (ScaleWidth - x1a(Pointer), y1a(Pointer))-(ScaleWidth - x2a(Pointer), y2a(Pointer)), l
  338.         Case 3: 'mirror around center point
  339.             Line (x1a(Pointer), y1a(Pointer))-(x2a(Pointer), y2a(Pointer)), l
  340.             Line (ScaleWidth - x1a(Pointer), ScaleHeight - y1a(Pointer))-(ScaleWidth - x2a(Pointer), ScaleHeight - y2a(Pointer)), l
  341.         Case Else: Mirror = 1' if invalid value set, then change
  342.         
  343.         End Select
  344.         'Move pointer to next item
  345.         Pointer = Pointer + 1
  346.         If Pointer > MaxLines Then
  347.             Pointer = 1
  348.         End If
  349.         'determine new acceleration
  350.         ax1 = Rnd - .5
  351.         ax2 = Rnd - .5
  352.         ay1 = Rnd - .5
  353.         ay2 = Rnd - .5
  354.         'calculate new position
  355.         x1 = x1 + vx1
  356.         x2 = x2 + vx2
  357.         y1 = y1 + vy1
  358.         y2 = y2 + vy2
  359.         'calculate new velocity
  360.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  361.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  362.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  363.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  364.         'check if off screen
  365.         If (x1 > ScaleWidth) Then
  366.             'change direction
  367.             vx1 = -Abs(vx1)
  368.         ElseIf (x1 < 0) Then
  369.             'change direction
  370.             vx1 = Abs(vx1)
  371.         End If
  372.         If (y1 > ScaleHeight) Then
  373.             'change direction
  374.             vy1 = -Abs(vy1)
  375.         ElseIf (y1 < 0) Then
  376.             'change direction
  377.             vy1 = Abs(vy1)
  378.         End If
  379.         If (x2 > ScaleWidth) Then
  380.             'change direction
  381.             vx2 = -Abs(vx2)
  382.         ElseIf (x2 < 0) Then
  383.             'change direction
  384.             vx2 = Abs(vx2)
  385.         End If
  386.         If (y2 > ScaleHeight) Then
  387.             'change direction
  388.             vy2 = -Abs(vy2)
  389.         ElseIf (y2 < 0) Then
  390.             'change direction
  391.             vy2 = Abs(vy2)
  392.         End If
  393.     End If
  394. End Sub
  395. Sub Kalied2 ()
  396.   ' have a line and its mirror images trace across the
  397.   ' screen with all the previous copies left on the screen
  398.   ' until the maximum is reached and the screen cleared
  399.   Dim i As Integer, j As Integer, k As Integer, N As Integer
  400.   Dim xRadius As Integer, yRadius As Integer
  401.   Dim HighMirror As Integer
  402.   ' if first time then initialize
  403.   If PlotInit = False Then
  404.     PlotInit = True
  405.     Cls
  406.     Forecolor = QBColor(15)
  407.     'select mirroring method
  408.     HighMirror = 3
  409.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  410.     Pointer = 1     ' set lines on screen to one
  411.     ' set index to count number of times to repeat color
  412.     '   to past maxvalue so that it will be recalculated
  413.     RepeatIndex = MaxLines + 1
  414.     'determine initial position of line
  415.     x1 = Rnd * ScaleWidth
  416.     x2 = Rnd * ScaleWidth
  417.     y1 = Rnd * ScaleHeight
  418.     y2 = Rnd * ScaleHeight
  419.     'set initial velocity
  420.     vx1 = 0
  421.     vx2 = 0
  422.     vy1 = 0
  423.     vy2 = 0
  424.     'set initial acceleration
  425.     ax1 = 0
  426.     ax2 = 0
  427.     ay1 = 0
  428.     ay2 = 0
  429.     'find background color
  430.     m = QBColor(0)
  431.     'Calculate velocity limits
  432.     MaxSpeedX = ScaleWidth * 15! / 800
  433.     MaxSpeedY = ScaleWidth * 15! / 600
  434.   Else  ' put run code here
  435.     ' check if time to get a new color
  436.     If RepeatIndex > RepeatCount Then
  437.         ' use rgb function
  438.         i = Rnd * 255: If i > 255 Then i = 255
  439.         j = Rnd * 255: If j > 255 Then j = 255
  440.         k = Rnd * 255: If k > 255 Then k = 255
  441.         l = RGB(i, j, k)
  442.         RepeatIndex = 1
  443.     Else
  444.         RepeatIndex = RepeatIndex + 1
  445.     End If
  446.         'Draw New Lines
  447.         Select Case Mirror
  448.         Case 1: 'mirror on x and y axis
  449.             Line (x1, y1)-(x2, y2), l
  450.             Line (ScaleWidth - x1, y1)-(ScaleWidth - x2, y2), l
  451.             Line (x1, ScaleHeight - y1)-(x2, ScaleHeight - y2), l
  452.             Line (ScaleWidth - x1, ScaleHeight - y1)-(ScaleWidth - x2, ScaleHeight - y2), l
  453.         Case 2: 'mirror on Y axis
  454.             Line (x1, y1)-(x2, y2), l
  455.             Line (ScaleWidth - x1, y1)-(ScaleWidth - x2, y2), l
  456.         Case 3: 'mirror around center point
  457.             Line (x1, y1)-(x2, y2), l
  458.             Line (ScaleWidth - x1, ScaleHeight - y1)-(ScaleWidth - x2, ScaleHeight - y2), l
  459.         
  460.         Case Else: Mirror = 1' if invalid value set, then change
  461.         
  462.         End Select
  463.         ' count total lines on screen
  464.         Pointer = Pointer + 1
  465.         If Pointer > MaxCums Then
  466.             'when maximum reached then clear
  467.             Cls
  468.             Pointer = 1
  469.         End If
  470.         'determine new acceleration
  471.         ax1 = Rnd - .5
  472.         ax2 = Rnd - .5
  473.         ay1 = Rnd - .5
  474.         ay2 = Rnd - .5
  475.         'calculate new position
  476.         x1 = x1 + vx1
  477.         x2 = x2 + vx2
  478.         y1 = y1 + vy1
  479.         y2 = y2 + vy2
  480.         'calculate new velocity
  481.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  482.         vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  483.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  484.         vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  485.         'check if off screen
  486.         If (x1 > ScaleWidth) Then
  487.             'change direction
  488.             vx1 = -Abs(vx1)
  489.         ElseIf (x1 < 0) Then
  490.             'change direction
  491.             vx1 = Abs(vx1)
  492.         End If
  493.         If (y1 > ScaleHeight) Then
  494.             'change direction
  495.             vy1 = -Abs(vy1)
  496.         ElseIf (y1 < 0) Then
  497.             'change direction
  498.             vy1 = Abs(vy1)
  499.         End If
  500.         If (x2 > ScaleWidth) Then
  501.             'change direction
  502.             vx2 = -Abs(vx2)
  503.         ElseIf (x2 < 0) Then
  504.             'change direction
  505.             vx2 = Abs(vx2)
  506.         End If
  507.         If (y2 > ScaleHeight) Then
  508.             'change direction
  509.             vy2 = -Abs(vy2)
  510.         ElseIf (y2 < 0) Then
  511.             'change direction
  512.             vy2 = Abs(vy2)
  513.         End If
  514.     End If
  515. End Sub
  516. Sub Lines ()
  517.   ' have a random number of lines trace across the
  518.   ' screen with multiple previous copies following
  519.   ' them
  520.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  521.   Static Sets As Integer
  522.   ' if first time then initialize
  523.   If PlotInit = False Then
  524.     PlotInit = True
  525.     Cls
  526.     Forecolor = QBColor(15)
  527.     'set number of sets between 1 and 4
  528.     Sets = Rnd * 3 + 1
  529.     'Set array size and clear the elements
  530.     ReDim x1da(MaxLines, Sets) As Integer
  531.     ReDim x2da(MaxLines, Sets) As Integer
  532.     ReDim y1da(MaxLines, Sets) As Integer
  533.     ReDim y2da(MaxLines, Sets) As Integer
  534.     ReDim x1sa(Sets) As Single
  535.     ReDim x2sa(Sets) As Single
  536.     ReDim y1sa(Sets) As Single
  537.     ReDim y2sa(Sets) As Single
  538.     ReDim vx1sa(Sets) As Single
  539.     ReDim vx2sa(Sets) As Single
  540.     ReDim vy1sa(Sets) As Single
  541.     ReDim vy2sa(Sets) As Single
  542.     ReDim ax1sa(Sets) As Single
  543.     ReDim ax2sa(Sets) As Single
  544.     ReDim ay1sa(Sets) As Single
  545.     ReDim ay2sa(Sets) As Single
  546.     ReDim Colors(Sets) As Long
  547.     Pointer = 1     ' start with array element 1
  548.     ' set index to count number of times to repeat color
  549.     '   to past maxvalue so that it will be recalculated
  550.     RepeatIndex = MaxLines + 1
  551.     For j = 1 To Sets
  552.         'determine initial position of line
  553.         x1sa(j) = Rnd * ScaleWidth
  554.         x2sa(j) = Rnd * ScaleWidth
  555.         y1sa(j) = Rnd * ScaleHeight
  556.         y2sa(j) = Rnd * ScaleHeight
  557.     Next j
  558.     'find background color
  559.     m = QBColor(0)
  560.     'Calculate velocity limits
  561.     MaxSpeedX = ScaleWidth * 15! / 800
  562.     MaxSpeedY = ScaleWidth * 15! / 600
  563.   Else  ' put run code here
  564.     ' check if time to get a new color
  565.     If RepeatIndex > RepeatCount Then
  566.         ' use rgb function
  567.         For ii = 1 To Sets
  568.             i = Rnd * 255: If i > 255 Then i = 255
  569.             j = Rnd * 255: If j > 255 Then j = 255
  570.             k = Rnd * 255: If k > 255 Then k = 255
  571.             Colors(ii) = RGB(i, j, k)
  572.         Next ii
  573.         RepeatIndex = 1
  574.     Else
  575.         RepeatIndex = RepeatIndex + 1
  576.     End If
  577.         'Delete original Lines
  578.         For j = 1 To Sets
  579.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  580.         Next j
  581.         For j = 1 To Sets
  582.             'Save New Lines
  583.             x1da(Pointer, j) = x1sa(j)
  584.             x2da(Pointer, j) = x2sa(j)
  585.             y1da(Pointer, j) = y1sa(j)
  586.             y2da(Pointer, j) = y2sa(j)
  587.             'Draw new Line
  588.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  589.         Next j
  590.         'Move pointer to next item
  591.         Pointer = Pointer + 1
  592.         If Pointer > MaxLines Then
  593.             Pointer = 1
  594.         End If
  595.         For j = 1 To Sets
  596.             'determine new acceleration
  597.             ax1sa(j) = Rnd - .5
  598.             ax2sa(j) = Rnd - .5
  599.             ay1sa(j) = Rnd - .5
  600.             ay2sa(j) = Rnd - .5
  601.             'calculate new position
  602.             x1sa(j) = x1sa(j) + vx1sa(j)
  603.             x2sa(j) = x2sa(j) + vx2sa(j)
  604.             y1sa(j) = y1sa(j) + vy1sa(j)
  605.             y2sa(j) = y2sa(j) + vy2sa(j)
  606.             'calculate new velocity
  607.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  608.             vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  609.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  610.             vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  611.             'check if off screen
  612.             If (x1sa(j) > ScaleWidth) Then
  613.                 'change direction
  614.                 vx1sa(j) = -Abs(vx1sa(j))
  615.             ElseIf (x1sa(j) < 0) Then
  616.                 'change direction
  617.                 vx1sa(j) = Abs(vx1sa(j))
  618.             End If
  619.             If (y1sa(j) > ScaleHeight) Then
  620.                 'change direction
  621.                 vy1sa(j) = -Abs(vy1sa(j))
  622.             ElseIf (y1sa(j) < 0) Then
  623.                 'change direction
  624.                 vy1sa(j) = Abs(vy1sa(j))
  625.             End If
  626.             If (x2sa(j) > ScaleWidth) Then
  627.                 'change direction
  628.                 vx2sa(j) = -Abs(vx2sa(j))
  629.             ElseIf (x2sa(j) < 0) Then
  630.                 'change direction
  631.                 vx2sa(j) = Abs(vx2sa(j))
  632.             End If
  633.             If (y2sa(j) > ScaleHeight) Then
  634.                 'change direction
  635.                 vy2sa(j) = -Abs(vy2sa(j))
  636.             ElseIf (y2sa(j) < 0) Then
  637.                 'change direction
  638.                 vy2sa(j) = Abs(vy2sa(j))
  639.             End If
  640.         Next j
  641.   End If
  642. End Sub
  643. Sub Patch ()
  644.   ' copy blocks of original screen to random spots
  645.   ' if first time then initialize
  646.   If PlotInit = False Then
  647.     ' set tick rate down
  648.     Tick.Interval = 250
  649.     ' start with original screen
  650.     Picture = Original.Image
  651.     PlotInit = True
  652.   Else  ' put run code here
  653.     BoxHeight = Rnd * ScaleHeight / 2.5
  654.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  655.     ' get random locations
  656.     x1 = Rnd * ScaleWidth
  657.     y1 = Rnd * ScaleHeight
  658.     x2 = Rnd * ScaleWidth
  659.     y2 = Rnd * ScaleHeight
  660.     'make sure room in destination and source blocks
  661.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  662.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  663.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  664.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  665.     'BitBlt Box from x2,y2 to x1,y1
  666.     DC = Original.hDC
  667.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020
  668.         
  669.   End If
  670. End Sub
  671. Sub Polygons ()
  672.   ' draw a randomly moving polygon on the screen
  673.   ' with multiple previous copies following it
  674.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  675.   Static Sets As Integer
  676.   ' if first time then initialize
  677.   If PlotInit = False Then
  678.     PlotInit = True
  679.     Cls
  680.     Forecolor = QBColor(15)
  681.     'set number of sets between 3 and 5
  682.     Sets = Rnd * 2 + 3
  683.     'Set array size and clear the elements
  684.     ReDim x1da(MaxLines, Sets) As Integer
  685.     ReDim y1da(MaxLines, Sets) As Integer
  686.     ReDim x1sa(Sets) As Single
  687.     ReDim y1sa(Sets) As Single
  688.     ReDim vx1sa(Sets) As Single
  689.     ReDim vy1sa(Sets) As Single
  690.     ReDim ax1sa(Sets) As Single
  691.     ReDim ay1sa(Sets) As Single
  692.     Pointer = 1     ' start with array element 1
  693.     ' set index to count number of times to repeat color
  694.     '   to past maxvalue so that it will be recalculated
  695.     RepeatIndex = MaxLines + 1
  696.     For j = 1 To Sets
  697.         'determine initial position of line
  698.         x1sa(j) = Rnd * ScaleWidth
  699.         y1sa(j) = Rnd * ScaleHeight
  700.     Next j
  701.     'find background color
  702.     m = QBColor(0)
  703.     'Calculate velocity limits
  704.     MaxSpeedX = ScaleWidth * 15! / 800
  705.     MaxSpeedY = ScaleWidth * 15! / 600
  706.   Else  ' put run code here
  707.     ' check if time to get a new color
  708.     If RepeatIndex > RepeatCount Then
  709.         i = Rnd * 255: If i > 255 Then i = 255
  710.         j = Rnd * 255: If j > 255 Then j = 255
  711.         k = Rnd * 255: If k > 255 Then k = 255
  712.         l = RGB(i, j, k)
  713.         
  714.         RepeatIndex = 1
  715.     Else
  716.         RepeatIndex = RepeatIndex + 1
  717.     End If
  718.         'Delete original Lines
  719.         Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  720.         For j = 3 To Sets
  721.             Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  722.         Next j
  723.         Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  724.         For j = 1 To Sets
  725.             'Save New Lines
  726.             x1da(Pointer, j) = x1sa(j)
  727.             y1da(Pointer, j) = y1sa(j)
  728.         Next j
  729.         'Draw New Lines
  730.         Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  731.         For j = 3 To Sets
  732.             Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  733.         Next j
  734.         Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  735.         'Move pointer to next item
  736.         Pointer = Pointer + 1
  737.         If Pointer > MaxLines Then
  738.             Pointer = 1
  739.         End If
  740.         For j = 1 To Sets
  741.             'determine new acceleration
  742.             ax1sa(j) = Rnd - .5
  743.             ay1sa(j) = Rnd - .5
  744.             
  745.             'calculate new position
  746.             x1sa(j) = x1sa(j) + vx1sa(j)
  747.             y1sa(j) = y1sa(j) + vy1sa(j)
  748.             'calculate new velocity
  749.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  750.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  751.             'check if off screen
  752.             If (x1sa(j) > ScaleWidth) Then
  753.                 'change direction
  754.                 vx1sa(j) = -Abs(vx1sa(j))
  755.             ElseIf (x1sa(j) < 0) Then
  756.                 'change direction
  757.                 vx1sa(j) = Abs(vx1sa(j))
  758.             End If
  759.             If (y1sa(j) > ScaleHeight) Then
  760.                 'change direction
  761.                 vy1sa(j) = -Abs(vy1sa(j))
  762.             ElseIf (y1sa(j) < 0) Then
  763.                 'change direction
  764.                 vy1sa(j) = Abs(vy1sa(j))
  765.             End If
  766.         Next j
  767.     End If
  768. End Sub
  769. Sub Puzzle ()
  770.   'scramble screen by shifting one column or row at a time
  771.   Dim tempx As Integer, tempy As Integer
  772.   Dim x As Integer, y As Integer
  773.   ' if first time then initialize
  774.   If PlotInit = False Then
  775.     ' set tick rate down
  776.     Tick.Interval = 1000
  777.     ' start with original screen
  778.     Picture = Original.Image
  779.     PlotInit = True
  780.     BoxHeight = ScaleHeight / 10
  781.     BoxWidth = ScaleWidth / 10
  782.     'initialize blocks
  783.     ReDim x1da(10, 10) As Integer
  784.     ReDim y1da(10, 10) As Integer
  785.     For x1 = 1 To 10
  786.         For y1 = 1 To 10
  787.             x1da(x1, y1) = (x1 - 1) * BoxWidth
  788.             y1da(x1, y1) = (y1 - 1) * BoxHeight
  789.         Next y1
  790.     Next x1
  791.   Else  ' put run code here
  792.     If Int(Rnd * 2) = 1 Then 'shift column
  793.         x1 = Rnd * 10 + 1: If x1 > 10 Then x1 = 1
  794.         If Int(Rnd * 2) = 1 Then 'shift down
  795.             tempx = x1da(x1, 10)
  796.             tempy = y1da(x1, 10)
  797.             For y1 = 10 To 2 Step -1
  798.                 x1da(x1, y1) = x1da(x1, y1 - 1)
  799.                 y1da(x1, y1) = y1da(x1, y1 - 1)
  800.                 'BitBlt Box to x1,y1
  801.                 DC = Original.hDC
  802.                 x = (x1 - 1) * BoxWidth
  803.                 y = (y1 - 1) * BoxHeight
  804.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  805.             Next y1
  806.             y1 = 1
  807.             x1da(x1, y1) = tempx
  808.             y1da(x1, y1) = tempy
  809.             'BitBlt Box to x1,y1
  810.             DC = Original.hDC
  811.             x = (x1 - 1) * BoxWidth
  812.             y = (y1 - 1) * BoxHeight
  813.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  814.         Else ' shift up
  815.             tempx = x1da(x1, 1)
  816.             tempy = y1da(x1, 1)
  817.             For y1 = 1 To 9
  818.                 x1da(x1, y1) = x1da(x1, y1 + 1)
  819.                 y1da(x1, y1) = y1da(x1, y1 + 1)
  820.                 'BitBlt Box to x1,y1
  821.                 DC = Original.hDC
  822.                 x = (x1 - 1) * BoxWidth
  823.                 y = (y1 - 1) * BoxHeight
  824.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  825.             Next y1
  826.             y1 = 10
  827.             x1da(x1, y1) = tempx
  828.             y1da(x1, y1) = tempy
  829.             'BitBlt Box to x1,y1
  830.             DC = Original.hDC
  831.             x = (x1 - 1) * BoxWidth
  832.             y = (y1 - 1) * BoxHeight
  833.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  834.         End If
  835.     Else ' shift row
  836.         
  837.         y1 = Rnd * 10 + 1: If y1 > 10 Then y1 = 1
  838.         If Int(Rnd * 2) = 1 Then 'shift right
  839.             tempx = x1da(10, y1)
  840.             tempy = y1da(10, y1)
  841.             For x1 = 10 To 2 Step -1
  842.                 x1da(x1, y1) = x1da(x1 - 1, y1)
  843.                 y1da(x1, y1) = y1da(x1 - 1, y1)
  844.                 'BitBlt Box to x1,y1
  845.                 DC = Original.hDC
  846.                 x = (x1 - 1) * BoxWidth
  847.                 y = (y1 - 1) * BoxHeight
  848.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  849.             Next x1
  850.             x1 = 1
  851.             x1da(x1, y1) = tempx
  852.             y1da(x1, y1) = tempy
  853.                 
  854.             'BitBlt Box to x1,y1
  855.             DC = Original.hDC
  856.             x = (x1 - 1) * BoxWidth
  857.             y = (y1 - 1) * BoxHeight
  858.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  859.         Else 'shift left
  860.             tempx = x1da(1, y1)
  861.             tempy = y1da(1, y1)
  862.             For x1 = 1 To 9
  863.                 x1da(x1, y1) = x1da(x1 + 1, y1)
  864.                 y1da(x1, y1) = y1da(x1 + 1, y1)
  865.                 'BitBlt Box to x1,y1
  866.                 DC = Original.hDC
  867.                 x = (x1 - 1) * BoxWidth
  868.                 y = (y1 - 1) * BoxHeight
  869.                 BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  870.             Next x1
  871.             x1 = 10
  872.             x1da(x1, y1) = tempx
  873.             y1da(x1, y1) = tempy
  874.                 
  875.             'BitBlt Box to x1,y1
  876.             DC = Original.hDC
  877.             x = (x1 - 1) * BoxWidth
  878.             y = (y1 - 1) * BoxHeight
  879.             BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  880.         End If
  881.     End If
  882.   End If
  883. End Sub
  884. Sub Roll ()
  885.   ' the display rolls both horizontally and vertically
  886.   Dim v As Integer
  887.   ' if first time then initialize
  888.   If PlotInit = False Then
  889.     ' start with original screen
  890.     Picture = Original.Image
  891.     PlotInit = True
  892.     'Calculate velocity limits
  893.     MaxSpeedX = ScaleWidth * 15! / 800
  894.     MaxSpeedY = ScaleWidth * 15! / 600
  895.     ' initial velocities
  896.     vy1 = 0: vx1 = 0
  897.     ' initial offset
  898.     x1 = 0: y1 = 0
  899.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  900.   Else  ' put run code here
  901.     DC = Original.hDC
  902.     If Direction Then
  903.         ' do vertical scroll
  904.         BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  905.         BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  906.     Else
  907.         ' do horizontal scroll
  908.         BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  909.         BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  910.     End If
  911.     'determine new acceleration
  912.     ax1 = Rnd - .5
  913.     ay1 = Rnd - .5
  914.             
  915.     'calculate new velocity
  916.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  917.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  918.     'find new roll amount
  919.     x1 = x1 + vx1
  920.     If x1 > ScaleWidth Then
  921.         x1 = x1 - ScaleWidth
  922.     Else
  923.         If x1 < 0 Then
  924.             x1 = x1 + ScaleWidth
  925.         End If
  926.     End If
  927.             
  928.     y1 = y1 + vy1
  929.     If y1 > ScaleHeight Then
  930.         y1 = y1 - ScaleHeight
  931.     Else
  932.         If y1 < 0 Then
  933.             y1 = y1 + ScaleHeight
  934.         End If
  935.     End If
  936.             
  937.   End If
  938. End Sub
  939. Sub Scrape ()
  940.   ' bitblt's with various patterns, dragging them
  941.   ' across the screen randomly
  942.   ' if first time then initialize
  943.   If PlotInit = False Then
  944.     ' start with original screen
  945.     Picture = Original.Image
  946.     PlotInit = True
  947.     'determine initial position of line
  948.     x1 = Rnd * ScaleWidth
  949.     y1 = Rnd * ScaleHeight
  950.     x2 = Rnd * ScaleWidth
  951.     y2 = Rnd * ScaleHeight
  952.     'Calculate velocity limits
  953.     MaxSpeedX = ScaleWidth * 15! / 800
  954.     MaxSpeedY = ScaleWidth * 15! / 600
  955.     BoxHeight = 400 * Rnd ^ 3 + 20
  956.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  957.     ' zero initial velocity
  958.     vx1 = 0: vy1 = 0
  959.     ' choose scrape type at random
  960.     i = Rnd * 16
  961.     Select Case i
  962.         Case 0: Pattern = &H42 'Black Out
  963.                 Locked = True
  964.         Case 1: Pattern = &HFF0062 'White Out
  965.                 Locked = True
  966.         Case 2: Pattern = &HBB0226 'MergePaint
  967.                 Locked = False
  968.         Case 3: Pattern = &HCC0020 'Source Copy
  969.                 Locked = False
  970.         Case 4: Pattern = &HCC0020 'Source Copy
  971.                 Locked = True
  972.                 Picture = LoadPicture() ' start with blank screen
  973.         Case 5: Pattern = &H330008 'Not source copy
  974.                 Locked = True
  975.         Case 6: Pattern = &H330008 'Not source copy
  976.                 Locked = False
  977.         Case 7: Pattern = &H1100A6 'not source erase
  978.                 Locked = True
  979.         Case 8: Pattern = &H1100A6 'not source erase
  980.                 Locked = False
  981.         Case 9: Pattern = &H440328 'source erase
  982.                 Locked = True
  983.         Case 10: Pattern = &H440328 'source erase
  984.                 Locked = False
  985.         Case 11: Pattern = &H660046 'source invert
  986.                 Locked = True
  987.         Case 12: Pattern = &H660046 'source invert
  988.                 Locked = False
  989.         Case 13: Pattern = &H8800C6 'source and
  990.                 Locked = False
  991.         Case 14: Pattern = &HEE0086 'source paint
  992.                 Locked = False
  993.         Case Else: Pattern = &H550009 'Invert Destination
  994.                 Locked = True
  995.     End Select
  996.   Else  ' put run code here
  997.         ' do locking if necessary
  998.         If Locked Then
  999.             x2 = x1: y2 = y1
  1000.         Else 'do offset
  1001.             x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  1002.             y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  1003.         End If
  1004.         'BitBlt Box at x1,y1
  1005.         DC = Original.hDC
  1006.         BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  1007.         
  1008.         'determine new acceleration
  1009.         ax1 = Rnd - .5
  1010.         ay1 = Rnd - .5
  1011.             
  1012.         'calculate new position
  1013.         x1 = x1 + vx1
  1014.         y1 = y1 + vy1
  1015.             
  1016.         'calculate new velocity
  1017.         vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1018.         vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1019.             
  1020.         'check if off screen
  1021.         If (x1 > ScaleWidth - BoxWidth) Then
  1022.             'change direction
  1023.             vx1 = -Abs(vx1)
  1024.         ElseIf (x1 < 0) Then
  1025.             'change direction
  1026.             vx1 = Abs(vx1)
  1027.         End If
  1028.         If (y1 > ScaleHeight - BoxHeight) Then
  1029.             'change direction
  1030.             vy1 = -Abs(vy1)
  1031.         ElseIf (y1 < 0) Then
  1032.             'change direction
  1033.             vy1 = Abs(vy1)
  1034.         End If
  1035.   End If
  1036. End Sub
  1037. Sub Squiggles ()
  1038.   ' draw multiple squiggles on the screen.
  1039.   ' each squiggle is assign a random color at the
  1040.   ' start, then the head travels randomly and the
  1041.   ' tail is erased
  1042.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, N As Integer
  1043.     Static SquigNumb As Integer
  1044.     Static SquigLen As Integer
  1045.     Static EndPointer As Integer, StartPointer As Integer
  1046.   ' if first time then initialize
  1047.   If PlotInit = False Then
  1048.     PlotInit = True
  1049.     Cls
  1050.     Forecolor = QBColor(15)
  1051.     SquigNumb = Rnd * 10 + 10
  1052.     SquigLen = Rnd * 100 + 50
  1053.     'Allocate Memory
  1054.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  1055.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  1056.     ReDim x1sa(SquigNumb) As Single
  1057.     ReDim y1sa(SquigNumb) As Single
  1058.     ReDim vx1sa(SquigNumb) As Single
  1059.     ReDim vy1sa(SquigNumb) As Single
  1060.     ReDim ax1sa(SquigNumb) As Single
  1061.     ReDim ay1sa(SquigNumb) As Single
  1062.     ReDim Colors(SquigNumb) As Long
  1063.     Pointer = 1
  1064.     'Print "Clearing Array"
  1065.     For j = 1 To SquigNumb
  1066.         'determine initial position of line
  1067.         x1sa(j) = Rnd * ScaleWidth
  1068.         y1sa(j) = Rnd * ScaleHeight
  1069.         For i = 1 To SquigLen
  1070.             x1da(i, j) = x1sa(j)
  1071.             y1da(i, j) = y1sa(j)
  1072.         Next i
  1073.     Next j
  1074.     'find background color
  1075.     m = QBColor(0)
  1076.     ' use rgb function to get colors
  1077.     For ii = 1 To SquigNumb
  1078.         i = Rnd * 255: If i > 255 Then i = 255
  1079.         j = Rnd * 255: If j > 255 Then j = 255
  1080.         k = Rnd * 255: If k > 255 Then k = 255
  1081.         Colors(ii) = RGB(i, j, k)
  1082.     Next ii
  1083.     'Calculate velocity limits
  1084.     MaxSpeedX = ScaleWidth * 15! / 800
  1085.     MaxSpeedY = ScaleWidth * 15! / 600
  1086.   Else  ' put run code here
  1087.         'find where tail line went to
  1088.         If Pointer < SquigLen Then
  1089.             EndPointer = Pointer + 1
  1090.         Else
  1091.             EndPointer = 1
  1092.         End If
  1093.         'find where new line goes
  1094.         If Pointer > 1 Then
  1095.             StartPointer = Pointer - 1
  1096.         Else
  1097.             StartPointer = SquigLen
  1098.         End If
  1099.         For j = 1 To SquigNumb
  1100.         
  1101.             'Erase tails of squigles
  1102.             Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  1103.             'Save new points
  1104.             x1da(Pointer, j) = x1sa(j)
  1105.             y1da(Pointer, j) = y1sa(j)
  1106.             'Draw front of Squigles
  1107.             Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  1108.         Next j
  1109.         'Move pointer to next item
  1110.         Pointer = Pointer + 1
  1111.         If Pointer > SquigLen Then
  1112.             Pointer = 1
  1113.         End If
  1114.         For j = 1 To SquigNumb
  1115.             'determine new acceleration
  1116.             ax1sa(j) = Rnd * 4 - 2
  1117.             ay1sa(j) = Rnd * 4 - 2
  1118.             'calculate new position
  1119.             x1sa(j) = x1sa(j) + vx1sa(j)
  1120.             y1sa(j) = y1sa(j) + vy1sa(j)
  1121.             'calculate new velocity
  1122.             vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  1123.             vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  1124.             'check if off screen
  1125.             If (x1sa(j) > ScaleWidth) Then
  1126.                 x1sa(j) = ScaleWidth
  1127.                 'change direction
  1128.                 vx1sa(j) = -Abs(vx1sa(j))
  1129.             ElseIf (x1sa(j) < 0) Then
  1130.                 x1sa(j) = 0
  1131.                 'change direction
  1132.                 vx1sa(j) = Abs(vx1sa(j))
  1133.             End If
  1134.             If (y1sa(j) > ScaleHeight) Then
  1135.                 y1sa(j) = ScaleHeight
  1136.                 'change direction
  1137.                 vy1sa(j) = -Abs(vy1sa(j))
  1138.             ElseIf (y1sa(j) < 0) Then
  1139.                 y1sa(j) = 0
  1140.                 'change direction
  1141.                 vy1sa(j) = Abs(vy1sa(j))
  1142.             End If
  1143.         Next j
  1144.   End If
  1145. End Sub
  1146. Sub Tick_Timer ()
  1147.     ' check elapsed time to see if need to change type of plot
  1148.     ' also check if past midnight
  1149.     CurrentTime = Timer
  1150.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  1151.         MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  1152.         ' get new plottype, but make sure it is not
  1153.         ' the same as the current one
  1154.         Do
  1155.             i = Rnd * (MaxPlotType + 1) 'choose next one at random
  1156.             If i > MaxPlotType Then i = 0
  1157.         Loop While (i = PlotType)
  1158.         PlotType = i
  1159.         PlotInit = False
  1160.                 
  1161.         Picture = LoadPicture()
  1162.         BackGround.AutoRedraw = False
  1163.         ClearArrays 'set arrays to zero size when not needed
  1164.         'reset tick rate
  1165.         Tick.Interval = 50
  1166.     End If
  1167.     LastTime = CurrentTime
  1168.     Select Case PlotType
  1169.         Case 0: Squiggles
  1170.         Case 1: Kalied2
  1171.         Case 2: Polygons
  1172.         Case 3: Circles
  1173.         Case 4: Kalied
  1174.         Case 5: Lines
  1175.         Case 6: Roll
  1176.         Case 7: Patch
  1177.         Case 8: Puzzle
  1178.         Case 9: Scrape
  1179.         Case 10: Scrape ' will be used twice as often
  1180.         Case Else: PlotType = 0
  1181.     End Select
  1182. End Sub
  1183.