home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_tools / manythng / manythng.frm < prev    next >
Text File  |  1994-09-28  |  101KB  |  4,109 lines

  1. VERSION 2.00
  2. Begin Form ManyThings 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   1845
  7.    ClientTop       =   1710
  8.    ClientWidth     =   7995
  9.    ControlBox      =   0   'False
  10.    Height          =   5010
  11.    Icon            =   MANYTHNG.FRX:0000
  12.    Left            =   1785
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   307
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   533
  17.    Top             =   1365
  18.    Width           =   8115
  19.    Begin Timer Tick 
  20.       Enabled         =   0   'False
  21.       Interval        =   50
  22.       Left            =   10
  23.       Top             =   10
  24.    End
  25.    Begin Label PasswordLabel 
  26.       Alignment       =   1  'Right Justify
  27.       BackColor       =   &H00FFFFFF&
  28.       BorderStyle     =   1  'Fixed Single
  29.       Caption         =   "Need Password    "
  30.       FontBold        =   -1  'True
  31.       FontItalic      =   0   'False
  32.       FontName        =   "Times New Roman"
  33.       FontSize        =   24.75
  34.       FontStrikethru  =   0   'False
  35.       FontUnderline   =   0   'False
  36.       Height          =   690
  37.       Left            =   2430
  38.       TabIndex        =   0
  39.       Top             =   3510
  40.       Visible         =   0   'False
  41.       Width           =   4470
  42.    End
  43. End
  44. ' BackGround -- this form expands to fill the whole
  45. '   screen and is used as the back drop for all the
  46. '   drawing
  47.  
  48. Option Explicit
  49.  
  50. ' variables declared here
  51. Dim MouseX, MouseY ' Last position of the mouse moves
  52. Dim LastX As Integer, LastY As Integer
  53. 'Dim conv2x As Single, conv2y As Single
  54. Dim LastTime As Long
  55. Dim CurrentTime As Long
  56. Dim LinkTime As Long
  57. Dim PlotType As Integer
  58. Dim PlotInit As Integer
  59. Dim PlotEnd As Integer
  60. Dim RepeatIndex As Integer
  61. Dim Pointer As Integer
  62. Dim Mirror As Integer
  63. Dim RunMode As Integer
  64. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  65. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  66. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  67. Dim l As Long
  68. Dim m As Long
  69. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  70. Dim TimeInterval As Long
  71. Dim MaxTime As Long
  72. Dim Repeats As Integer
  73. Dim i As Integer
  74. Dim BoxHeight As Integer, BoxWidth As Integer
  75. Dim DC As Integer
  76. Dim Pattern As Long, Locked As Integer
  77. Dim Direction As Integer
  78. Dim Number As Integer
  79. Dim PicWidth As Integer, PicHeight As Integer
  80. Dim PriorityBreakPoints() As Single
  81. Dim Priorities() As Integer
  82. Dim TotalPriority As Single
  83. Dim MaxPlotType As Integer
  84.  
  85. ' values for GetBrightNonGray:
  86. ' minimum magnitude squared of colors
  87. Const MinColor = 3000' was 10000
  88. ' minimum difference between colors
  89. Const MinDiff = 30
  90.  
  91. 'Allocate Memory
  92. Dim x1a() As Integer
  93. Dim x2a() As Integer
  94. Dim y1a() As Integer
  95. Dim y2a() As Integer
  96. Dim x1da() As Integer
  97. Dim x2da() As Integer
  98. Dim y1da() As Integer
  99. Dim y2da() As Integer
  100. Dim x1sa() As Single
  101. Dim x2sa() As Single
  102. Dim y1sa() As Single
  103. Dim y2sa() As Single
  104. Dim vx1sa() As Single
  105. Dim vx2sa() As Single
  106. Dim vy1sa() As Single
  107. Dim vy2sa() As Single
  108. Dim ax1sa() As Single
  109. Dim ax2sa() As Single
  110. Dim ay1sa() As Single
  111. Dim ay2sa() As Single
  112. Dim Colors() As Long
  113. Dim DataPts() As Integer
  114.  
  115. 'for filled polygons
  116. Dim Points() As POINTAPI
  117.  
  118. Const PI = 3.14159265358979
  119. Const Sin45 = .707106781186547
  120. Const Cos45 = Sin45
  121. Const Sin22_5 = .38268343236509
  122. Const Cos22_5 = .923879532511287
  123. Const Sin11_25 = .195090322016128
  124. Const Cos11_25 = .98078528040323
  125. Const HighMirror = 10
  126.  
  127. Function CheckIfValidSaver (NeedsMuchMemory As Integer) As Integer
  128.   'when in low memory mode the saver only runs the modules
  129.   'that draw on the screen, not those that manipulate
  130.   'bitmaps, savers that use more memory will pass
  131.   'NeedsMuchMemory as a non-zero value
  132.  
  133.   If LowMemoryFlag = 0 Then 'if not low memory mode then done
  134.     CheckIfValidSaver = 1
  135.   Else
  136.     If NeedsMuchMemory <> 0 Then
  137.       LogFile ("Saver not valid in low memory: " + Str$(PlotType)), 0
  138.       NextSelection
  139.       CheckIfValidSaver = 0
  140.     Else
  141.       CheckIfValidSaver = 1
  142.     End If
  143.  
  144.   End If
  145.  
  146.   If Priorities(PlotType) = 0 Then
  147.     LogFile ("Saver disabled: " + Str$(PlotType)), 0
  148.     NextSelection
  149.     CheckIfValidSaver = 0
  150.   End If
  151.  
  152. End Function
  153.  
  154. Sub Circles ()
  155.   
  156.   ' have a single elipse trace across the
  157.   ' screen with multiple previous copies following
  158.   ' it
  159.  
  160.   Dim xRadius As Integer, yRadius As Integer
  161.   Dim HighMirror As Integer
  162.  
  163.   ' if first time then initialize
  164.   If PlotInit = False Then
  165.  
  166.    'see if we need to reset changes made from previous init
  167.    If PlotEnd = False Then
  168.  
  169.     'check if saver is permitted to run
  170.     If CheckIfValidSaver(0) = 0 Then
  171.       Exit Sub
  172.     End If
  173.     
  174.     PlotInit = True
  175.     Cls
  176.     ForeColor = QBColor(15)
  177.  
  178.     'Set array size and clear the elements
  179.     ReDim x1a(MaxLines) As Integer
  180.     ReDim x2a(MaxLines) As Integer
  181.     ReDim y1a(MaxLines) As Integer
  182.     ReDim y2a(MaxLines) As Integer
  183.  
  184.     Pointer = 1     ' start with array element 1
  185.     
  186.     ' set index to count number of times to repeat color
  187.     '   to past maxvalue so that it will be recalculated
  188.     RepeatIndex = MaxLines + 1
  189.  
  190.     'determine initial position of line
  191.     x1 = Rnd * ScaleWidth
  192.     x2 = Rnd * ScaleWidth
  193.     y1 = Rnd * ScaleHeight
  194.     y2 = Rnd * ScaleHeight
  195.  
  196.     'set initial velocity
  197.     vx1 = 0
  198.     vx2 = 0
  199.     vy1 = 0
  200.     vy2 = 0
  201.  
  202.     'set initial acceleration
  203.     ax1 = 0
  204.     ax2 = 0
  205.     ay1 = 0
  206.     ay2 = 0
  207.     
  208.     'find background color
  209.     m = QBColor(0)
  210.  
  211.     'Calculate velocity limits
  212.     MaxSpeedX = ScaleWidth * 15! / 800
  213.     MaxSpeedY = ScaleWidth * 15! / 600
  214.  
  215.     'select mirroring method
  216.     HighMirror = 5
  217.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  218.  
  219.   Else 'reset changes done by previous init
  220.  
  221.     ClearScreen
  222.  
  223.     'zero array sizes
  224.     ReDim x1a(0) As Integer
  225.     ReDim x2a(0) As Integer
  226.     ReDim y1a(0) As Integer
  227.     ReDim y2a(0) As Integer
  228.  
  229.   End If
  230.  
  231.   Else  ' put run code here
  232.  
  233.     Tick.Enabled = False' disable timer until circles completed
  234.  
  235.     ' check if time to get a new color
  236.     If RepeatIndex > RepeatCount Then
  237.     
  238.     'set color
  239.     l = GetBrightNonGray()
  240.  
  241.     RepeatIndex = 1
  242.     Else
  243.     RepeatIndex = RepeatIndex + 1
  244.     End If
  245.  
  246.     'Delete original circle
  247.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  248.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  249.     If xRadius <> 0 Then
  250.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  251.     End If
  252.  
  253.     DoEvents
  254.  
  255.     Select Case Mirror
  256.     Case 1: 'mirror on x and y axis
  257.         
  258.         'Delete original circle mirrored on Y axis
  259.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  260.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  261.         If xRadius <> 0 Then
  262.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  263.         End If
  264.  
  265.         DoEvents
  266.  
  267.         'Delete original circle mirrored on X axis
  268.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  269.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  270.         If xRadius <> 0 Then
  271.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  272.         End If
  273.  
  274.         DoEvents
  275.  
  276.         'Delete original circle mirrored on origin
  277.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  278.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  279.         If xRadius <> 0 Then
  280.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  281.         End If
  282.  
  283.         DoEvents
  284.  
  285.     Case 2: 'mirror on Y axis
  286.         
  287.         'Delete original circle mirrored on Y axis
  288.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  289.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  290.         If xRadius <> 0 Then
  291.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  292.         End If
  293.  
  294.         DoEvents
  295.  
  296.     Case 3: 'mirror around center point
  297.     
  298.         'Delete original circle mirrored on origin
  299.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  300.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  301.         If xRadius <> 0 Then
  302.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  303.         End If
  304.  
  305.         DoEvents
  306.  
  307.     Case Else: ' otherwise ignore (i.e. no mirror)
  308.     
  309.     End Select
  310.  
  311.     'Save New Circle
  312.     x1a(Pointer) = x1
  313.     x2a(Pointer) = x2
  314.     y1a(Pointer) = y1
  315.     y2a(Pointer) = y2
  316.  
  317.     Select Case Mirror
  318.     Case 1: 'mirror on x and y axis
  319.         
  320.         'Delete original circle mirrored on Y axis
  321.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  322.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  323.         If xRadius <> 0 Then
  324.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  325.         End If
  326.  
  327.         DoEvents
  328.  
  329.         'Delete original circle mirrored on X axis
  330.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  331.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  332.         If xRadius <> 0 Then
  333.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  334.         End If
  335.  
  336.         DoEvents
  337.  
  338.         'Delete original circle mirrored on origin
  339.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  340.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  341.         If xRadius <> 0 Then
  342.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  343.         End If
  344.  
  345.     Case 2: 'mirror on Y axis
  346.         
  347.         'Delete original circle mirrored on y axis
  348.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  349.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  350.         If xRadius <> 0 Then
  351.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  352.         End If
  353.  
  354.     Case 3: 'mirror around center point
  355.     
  356.         'Delete original circle mirrored on origin
  357.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  358.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  359.         If xRadius <> 0 Then
  360.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  361.         End If
  362.  
  363.     Case Else: ' otherwise ignore (i.e. no mirror)
  364.     
  365.     End Select
  366.  
  367.     DoEvents
  368.  
  369.     Tick.Enabled = True' re-enable timer
  370.  
  371.     'Draw new Circle
  372.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  373.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  374.     If xRadius <> 0 Then
  375.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  376.     End If
  377.  
  378.     'Move pointer to next item
  379.     Pointer = Pointer + 1
  380.     If Pointer > MaxLines Then
  381.         Pointer = 1
  382.     End If
  383.  
  384.     'determine new acceleration
  385.     ax1 = Rnd - .5
  386.     ax2 = Rnd - .5
  387.     ay1 = Rnd - .5
  388.     ay2 = Rnd - .5
  389.  
  390.     'calculate new position
  391.     x1 = x1 + vx1
  392.     x2 = x2 + vx2
  393.     y1 = y1 + vy1
  394.     y2 = y2 + vy2
  395.  
  396.     'calculate new velocity
  397.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  398.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  399.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  400.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  401.  
  402.     'check if off screen
  403.     If (x1 > ScaleWidth) Then
  404.         'change direction
  405.         vx1 = -Abs(vx1)
  406.     ElseIf (x1 < 0) Then
  407.         'change direction
  408.         vx1 = Abs(vx1)
  409.     End If
  410.  
  411.     If (y1 > ScaleHeight) Then
  412.         'change direction
  413.         vy1 = -Abs(vy1)
  414.     ElseIf (y1 < 0) Then
  415.         'change direction
  416.         vy1 = Abs(vy1)
  417.     End If
  418.  
  419.     If (x2 > ScaleWidth) Then
  420.         'change direction
  421.         vx2 = -Abs(vx2)
  422.     ElseIf (x2 < 0) Then
  423.         'change direction
  424.         vx2 = Abs(vx2)
  425.     End If
  426.  
  427.     If (y2 > ScaleHeight) Then
  428.         'change direction
  429.         vy2 = -Abs(vy2)
  430.     ElseIf (y2 < 0) Then
  431.         'change direction
  432.         vy2 = Abs(vy2)
  433.     End If
  434.  
  435.  
  436.   End If
  437.  
  438. End Sub
  439.  
  440. Sub ClearScreen ()
  441. 'goes to extreme efforts to clear the screen
  442.  
  443.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  444.   'clear display
  445.   BitBlt DC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &H42&
  446.   i = DeleteDC(DC)
  447.  
  448.   picture = LoadPicture() ' clear picture
  449.   BackColor = QBColor(0)
  450.   Cls
  451.  
  452. End Sub
  453.  
  454. Sub Confetti ()
  455.  
  456.   'put points on screen
  457.   'Dim i As Integer, j As Integer, k As Integer
  458.   Dim x As Integer, y As Integer
  459.   Dim Size As Integer
  460.   Dim UniformBoxes As Integer
  461.  
  462.   ' if first time then initialize
  463.   If PlotInit = False Then
  464.     
  465.     'see if we need to reset changes made from previous init
  466.     If PlotEnd = False Then
  467.     
  468.       'check if saver is permitted to run
  469.       If CheckIfValidSaver(0) = 0 Then
  470.     Exit Sub
  471.       End If
  472.  
  473.      If LowMemoryFlag = 0 Then 'if not low memory mode then done
  474.        picture = original.Image ' start with original screen
  475.      Else
  476.        Cls
  477.      End If
  478.  
  479.       PlotInit = True
  480.       Size = Rnd * 5 + 1
  481.  
  482.     Else 'reset changes done by previous init
  483.  
  484.       Tick.Enabled = True
  485.       picture = LoadPicture()
  486.  
  487.     End If
  488.  
  489.   Else
  490.  
  491.     Tick.Enabled = False
  492.   
  493.     Size = Rnd * 5 + 1  ' size to make dots
  494.  
  495.     If Rnd > .5 Then
  496.        UniformBoxes = True
  497.     Else
  498.        UniformBoxes = False
  499.     End If
  500.  
  501.     Do
  502.       x = Int(Rnd * ScrnWidth)
  503.       y = Int(Rnd * ScrnHeight)
  504.       Line (x, y)-(x + Size, y + Size), GetNearestColor(hDC, RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))), BF
  505.  
  506.       If UniformBoxes = False Then
  507.     Size = Rnd ^ 10 * 40 + 2'new size
  508.       End If
  509.  
  510.       DoEvents
  511.       CurrentTime = Timer
  512.       If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Do
  513.     Loop
  514.  
  515.     Tick.Enabled = True
  516.     picture = LoadPicture()
  517.  
  518.   End If
  519.  
  520. End Sub
  521.  
  522. Sub CyclePalette ()
  523.  
  524.   Dim Header As Long, DataBits As Long, i As Integer, j As Integer
  525.   Dim l As Long
  526.   Dim Paint As PAINTSTRUCT
  527.   Static Xoffset As Integer, Yoffset As Integer, red As Integer, green As Integer, blue As Integer
  528.   Static Wdth As Integer, Hght As Integer
  529.   Static FastPalRunFlag As Integer, PassFlag As Integer
  530.   Dim FileName As String, File As String
  531.   Static PaletteFlag As Integer
  532.  
  533.   ' if first time then initialize
  534.   If PlotInit = False Then
  535.     
  536.     'see if we need to reset changes made from previous init
  537.     If PlotEnd = False Then
  538.     
  539.     'check if saver is permitted to run
  540.     If CheckIfValidSaver(1) = 0 Then
  541.       Exit Sub
  542.     End If
  543.  
  544.      'we only allow to run once since it has problems:
  545.      'if started more than once durring before program stops
  546.      'then resources can disappear drastically, there must
  547.      'be something about the animatepalette function or
  548.      'sendmessage that requires resources to be cleared?
  549.      If FastPalRunFlag Then
  550.        LogFile "Already ran Fast pallete cycle " + File, 1
  551.        NextSelection 'jump to next since there are no bitmap files in directory
  552.        Exit Sub
  553.      End If
  554.  
  555.       '*****************************************************
  556.       'initialization code here:
  557.       File = GetNextFile(CycleBitmapsDir, 1, "dib", "gif", "")
  558.  
  559.       If File = "" Then 'check if could not load
  560.     NextSelection 'jump to next since there are no bitmap files in directory
  561.     Exit Sub
  562.       End If
  563.  
  564.       ' find file
  565.       'FileSpec = RTrim$(BitmapsDir) + "\*.dib"
  566.       j = Rnd * 50 ' pick file at random
  567.       For i = 1 To j
  568.  
  569.     File = GetNextFile(CycleBitmapsDir, 0, "dib", "gif", "")' get next file
  570.  
  571.       Next i
  572.  
  573.       'i = LoadSlide(File, 1)
  574.       'If i = 0 Then 'check if could not load
  575.       '  LogFile "Could not load file " + File, 1
  576.       '  NextSelection 'jump to next since there are no bitmap files in directory
  577.       '  Exit Sub
  578.       'End If
  579.  
  580.       If InStr(UCase$(File), ".GIF") = 0 Then
  581.     l = ManyDibLoad(File, Wdth, Hght)'load dib
  582.       
  583.     If l <= 0 Then 'check if could not load
  584.       LogFile "Could not read DIB file " + File, 1
  585.       NextSelection 'jump to next since there are no bitmap files in directory
  586.       Exit Sub
  587.     End If
  588.       
  589.       Else
  590.     l = ManyGifLoad(File, Wdth, Hght)'load gif
  591.       
  592.     If l <= 0 Then 'check if could not load
  593.       LogFile "Could not read GIF file " + File, 1
  594.       NextSelection 'jump to next since there are no bitmap files in directory
  595.       Exit Sub
  596.     End If
  597.  
  598.       End If
  599.  
  600.       If (TotalNumColors <= 256) And (FastPaletteCycleFlag <> 0) Then
  601.  
  602.     FastPalRunFlag = 1
  603.  
  604.     'free up all but 2 system palettes
  605.     i = SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC)
  606.  
  607.     'show the palettes
  608.     SetWindow2DIBPalette PC_RESERVED
  609.     LogFile "Using Fast Palette Cycling", 0
  610.     PaletteFlag = 1
  611.  
  612.       Else 'don't mess with palettes
  613.  
  614.     'picture = LoadPicture() ' clear screen
  615.     LogFile "Changing Palette using screen redraws", 0
  616.     PaletteFlag = 0
  617.  
  618.       End If
  619.  
  620.       PassFlag = 2
  621.       
  622.       PlotInit = True
  623.       'Cls
  624.  
  625.       'position image
  626.       Xoffset = (ScrnWidth - Wdth) / 2
  627.       Yoffset = (ScrnHeight - Hght) / 2
  628.  
  629.       'set tick rate
  630.       Tick.Interval = 25
  631.  
  632.     Else 'reset changes done by previous init
  633.  
  634.       If PaletteFlag <> 0 Then
  635.  
  636.     'remove priority on palette entries
  637.     SetWindow2DIBPalette 0
  638.  
  639.     i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  640.  
  641.       End If
  642.  
  643.       'try to read last temp file for background
  644.       i = LoadSlideAndTile(RTrim$(BitmapsDir) + "\tmprary.dib")
  645.  
  646.       'save current screen as new original
  647.       DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  648.       BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  649.       i = DeleteDC(DC)
  650.  
  651.       ClearScreen
  652.  
  653.       i = ManyDibFree() 'free memory used for dib
  654.       If i <> 0 Then
  655.     LogFile "Could not free memory", 1
  656.       End If
  657.  
  658.       'set tick rate
  659.       Tick.Interval = 50
  660.  
  661.     End If
  662.  
  663.     
  664.   Else  ' put run code here
  665.  
  666.     If PassFlag > 1 Then
  667.  
  668.       Header = ManyDibGet() 'get pointer to header
  669.       DataBits = ManyDibGetData() 'get pointer to data
  670.  
  671.       If Header <> 0 Then
  672.  
  673.     i = SetStretchBltMode(hDC, 3)
  674.     i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, Wdth, Hght, DataBits, Header, 0, &HCC0020)'source copy
  675.       Else
  676.     LogFile "Header missing", 1
  677.     NextSelection
  678.     Exit Sub
  679.       End If
  680.  
  681.       PassFlag = PassFlag - 1
  682.     Else
  683.       
  684.       Header = ManyDibGet() 'get pointer to header
  685.       DataBits = ManyDibGetData() 'get pointer to data
  686.  
  687.       If Header <> 0 Then
  688.  
  689.     If PaletteFlag <> 0 Then
  690.  
  691.       DoAnimatePalette Pal, 1, 1'shift pallete by one
  692.  
  693.     Else 'if not palette based, animate screen by
  694.          'changing colors and redrawing
  695.          
  696.       'draw screen
  697.       i = SetStretchBltMode(hDC, 3)
  698.       ManyDibCyclePalette -1, 1, 255'cycle colors
  699.       'i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, 640, 480, DataBits, Header, 0, &HCC0020)'source copy
  700.       i = SetDIBitsToDevice(hDC, Xoffset, Yoffset, Wdth, Hght, 0, 0, 0, Hght, DataBits, Header, 0)
  701.  
  702.     End If
  703.     
  704.       Else
  705.     LogFile "Header missing", 1
  706.     NextSelection
  707.     Exit Sub
  708.       End If
  709.  
  710.     End If
  711.     
  712.   End If
  713.  
  714.   Exit Sub
  715.  
  716. End Sub
  717.  
  718. Sub DoAnimatePalette (palette As LOGPALETTE, Start As Integer, StepSize As Integer)
  719. ' cycle palete entry and display
  720.  
  721.     Dim entrynum%, i As Integer
  722.     Dim usepal As Integer
  723.     Dim holdentry As PALETTEENTRY
  724.     Dim temp As Long
  725.  
  726.     For i = 1 To StepSize'shift n times
  727.  
  728.       ' The following code simply loops the color values
  729.       LSet holdentry = palette.palPalEntry(Start)
  730.       For entrynum% = Start To PALENTRIES - 2
  731.     LSet palette.palPalEntry(entrynum%) = palette.palPalEntry(entrynum% + 1)
  732.       Next entrynum%
  733.       LSet palette.palPalEntry(PALENTRIES - 1) = holdentry
  734.  
  735.     Next i
  736.  
  737.     ' Get a handle to the control's palette
  738.     On Error GoTo DoAnimatePaletteError
  739.     usepal = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  740.     On Error GoTo 0
  741.    
  742.     AnimatePalette usepal, 0, PALENTRIES, palette.palPalEntry(0)
  743.  
  744.     Exit Sub
  745.  
  746. DoAnimatePaletteError:
  747.   'overflow on getting palette handle
  748.   On Error GoTo 0
  749.   LogFile "Overflow on getting palette handle", 1
  750.   Exit Sub
  751. End Sub
  752.  
  753. Sub Dribble ()
  754.  
  755.   'dribbling paint on screen
  756.  
  757.   Dim i As Integer, j As Integer, k As Integer
  758.   Static MaxHole As Integer
  759.  
  760.   ' if first time then initialize
  761.   If PlotInit = False Then
  762.     
  763.     'see if we need to reset changes made from previous init
  764.     If PlotEnd = False Then
  765.     
  766.     'check if saver is permitted to run
  767.     If CheckIfValidSaver(1) = 0 Then
  768.       Exit Sub
  769.     End If
  770.     
  771.     ' start with original screen
  772.     picture = original.Image
  773.     
  774.     PlotInit = True
  775.  
  776.     'determine initial position of shot
  777.     x1 = Rnd * ScaleWidth
  778.     y1 = Rnd * ScaleHeight
  779.     
  780.     'Calculate velocity limits
  781.     MaxSpeedX = ScaleWidth * 20! / 800
  782.     MaxSpeedY = ScaleWidth * 20! / 600
  783.  
  784.     ' zero initial velocity
  785.     vx1 = 0: vy1 = 0
  786.  
  787.     'set maximum size of holes
  788.     MaxHole = 4
  789.  
  790.     ForeColor = RGB(0, 0, 0)' use black box
  791.     FillColor = RGB(0, 0, 0) 'set black fill
  792.     FillStyle = 0 'solid fill
  793.  
  794.     RunMode = Int(Rnd * 2#)'choose black or color
  795.  
  796.     'Debug.Print RunMode
  797.  
  798.     If RunMode > 0 Then ' if random color then use larger spots
  799.     MaxHole = 8
  800.     i = Rnd * 255: If i > 255 Then i = 255
  801.     j = Rnd * 255: If j > 255 Then j = 255
  802.     k = Rnd * 255: If k > 255 Then k = 255
  803.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  804.     FillColor = ForeColor
  805.     End If
  806.  
  807.   Else 'reset changes done by previous init
  808.  
  809.     ClearScreen
  810.     FillStyle = 1 'transparent fill
  811.  
  812.   End If
  813.  
  814.   Else  ' put run code here
  815.  
  816.     If RunMode > 0 Then ' see if need to change to random color
  817.  
  818.         If Rnd < .05 Then
  819.         i = Rnd * 255: If i > 255 Then i = 255
  820.         j = Rnd * 255: If j > 255 Then j = 255
  821.         k = Rnd * 255: If k > 255 Then k = 255
  822.         ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  823.         FillColor = ForeColor
  824.         End If
  825.  
  826.     End If
  827.     
  828.     ' put random hole here
  829.     Circle (x1 + Rnd * 20, y1 + Rnd * 20), MaxHole * Rnd + 2, , , , 1
  830.  
  831.     'determine new acceleration
  832.     ax1 = 2 * Rnd - 1
  833.     ay1 = 2 * Rnd - 1
  834.         
  835.     'calculate new position
  836.     x1 = x1 + vx1
  837.     y1 = y1 + vy1
  838.         
  839.     'calculate new velocity
  840.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ax1 = 0
  841.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ay1 = 0
  842.         
  843.     'check if off screen
  844.     If (x1 > ScaleWidth) Then
  845.         'change direction
  846.         vx1 = -Abs(vx1)
  847.     ElseIf (x1 < 0) Then
  848.         'change direction
  849.         vx1 = Abs(vx1)
  850.     End If
  851.  
  852.     If (y1 > ScaleHeight) Then
  853.         'change direction
  854.         vy1 = -Abs(vy1)
  855.     ElseIf (y1 < 0) Then
  856.         'change direction
  857.         vy1 = Abs(vy1)
  858.     End If
  859.  
  860.   End If
  861.  
  862. End Sub
  863.  
  864. Sub Drop ()
  865.  
  866.   ' bitblt's with various patterns, dragging them
  867.   ' across the screen randomly
  868.  
  869.   Dim j As Integer
  870.   Static OldY As Integer
  871.   Static NotFoundCount As Integer
  872.   Const MaxCount = 200
  873.  
  874.   ' if first time then initialize
  875.   If PlotInit = False Then
  876.  
  877.     'see if we need to reset changes made from previous init
  878.     If PlotEnd = False Then
  879.     
  880.     'check if saver is permitted to run
  881.     If CheckIfValidSaver(1) = 0 Then
  882.       Exit Sub
  883.     End If
  884.     
  885.     'store whether column has dropped
  886.     ReDim x1a(ScaleWidth)
  887.  
  888.     ' start with original screen
  889.     picture = original.Image
  890.  
  891.     PlotInit = True
  892.  
  893.     'flag that no column has been chosen
  894.     x1 = -1
  895.  
  896.     'Calculate velocity limits
  897.     MaxSpeedY = ScaleWidth * 10! / 600
  898.     MaxSpeedX = ScaleWidth * 10! / 800
  899.  
  900.     ' zero initial velocity
  901.     vy1 = 0
  902.  
  903.     'width of column to drop
  904.     BoxWidth = 10 + Rnd * 100
  905.  
  906.     i = Int(Rnd * 2#)'if i=0 then do jagged drop
  907.  
  908.     x2 = 0 'used for width change
  909.  
  910.   Else 'reset changes done by previous init
  911.  
  912.     'store whether column has dropped
  913.     ReDim x1a(0)
  914.     ClearScreen
  915.  
  916.   End If
  917.  
  918. Else  ' put run code here
  919.  
  920.   If x1 < 0 Then 'see if found valid column
  921.  
  922.     x1 = Rnd * ScaleWidth / BoxWidth 'choose a column
  923.     
  924.     If x1a(x1) = 0 Then 'check if not yet dropped
  925.     y1 = 0 'start position
  926.     x1a(x1) = 1 'flag that column has already been used
  927.     x2 = 0: vx2 = 0: OldY = 0' initialize variables
  928.     NotFoundCount = 0
  929.  
  930.     Else
  931.     x1 = -1 'flag that no column chosen
  932.  
  933.     ' count column failures
  934.     NotFoundCount = NotFoundCount + 1
  935.     If NotFoundCount > MaxCount Then
  936.     
  937.         'restart dropping
  938.  
  939.         'reset whether column has dropped
  940.         ReDim x1a(ScaleWidth)
  941.  
  942.         ' start with original screen
  943.         picture = original.Image
  944.  
  945.     End If
  946.     End If
  947.  
  948.   Else 'if column already found, then drop it
  949.  
  950.     If i = 0 Then 'check if jagged drop
  951.  
  952.     'make sure effective width does not get too small
  953.     If x2 >= BoxWidth - 5 Then
  954.     x2 = BoxWidth - 5
  955.     vx2 = -vx2 'reverse direction
  956.     End If
  957.  
  958.     j = x2 / 2 'get half of change
  959.  
  960.     'shift column
  961.     DC = original.hDC
  962.     BitBlt hDC, x1 * BoxWidth + j, y1, BoxWidth - x2, ScaleHeight - y1, DC, x1 * BoxWidth + j, 0, &HCC0020'source copy
  963.     
  964.     'blank top of column
  965.     BitBlt hDC, x1 * BoxWidth + j, OldY, BoxWidth - x2, y1 - OldY + 1, DC, x1 * BoxWidth + j, 0, &H42'blackout
  966.     
  967.     Else ' not jagged drop
  968.  
  969.     'shift column
  970.     DC = original.hDC
  971.     BitBlt hDC, x1 * BoxWidth, y1, BoxWidth, ScaleHeight - y1, DC, x1 * BoxWidth, 0, &HCC0020  'source copy
  972.     
  973.     'blank top of column
  974.     BitBlt hDC, x1 * BoxWidth, OldY, BoxWidth, y1 - OldY + 1, DC, x1 * BoxWidth, 0, &H42'blackout
  975.     
  976.     End If
  977.  
  978.     'save current position
  979.     OldY = y1
  980.  
  981.     'check if off screen
  982.     If (y1 > ScaleHeight) Then
  983.     x1 = -1 'flag done
  984.     vy1 = 0'zero velocity again
  985.     End If
  986.  
  987.     'determine new acceleration
  988.     ay1 = Rnd * .25
  989.     ax2 = Rnd * .25 - .125
  990.     
  991.     'calculate new positions
  992.     y1 = y1 + vy1
  993.     x2 = x2 + vx2
  994.     
  995.     'calculate new velocity
  996.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = vy1 / 2: ay1 = 0
  997.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = vx2 / 2: ax2 = 0
  998.     
  999.     End If
  1000.  
  1001.   End If
  1002.  
  1003. End Sub
  1004.  
  1005. Sub EndScrnSaveForm ()
  1006.   LogFile "EndScrnSaveFrom: before freeing memory", 1
  1007.   i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  1008.  
  1009.   i = ManyDibFree() 'free memory used for dib
  1010.   If i <> 0 Then
  1011.     LogFile "Could not free memory", 1
  1012.   End If
  1013.  
  1014.   picture = LoadPicture()
  1015.   EndScrnSave 'call global screen saver
  1016. End Sub
  1017.  
  1018. Sub FilledCircles ()
  1019.   
  1020.   ' have a single filled elipse trace across the screen
  1021.  
  1022.   Dim i As Integer, j As Integer, k As Integer, n As Integer
  1023.   Dim xRadius As Integer, yRadius As Integer
  1024.  
  1025.   ' if first time then initialize
  1026.   If PlotInit = False Then
  1027.  
  1028.     'see if we need to reset changes made from previous init
  1029.     If PlotEnd = False Then
  1030.  
  1031.     'check if saver is permitted to run
  1032.     If CheckIfValidSaver(0) = 0 Then
  1033.       Exit Sub
  1034.     End If
  1035.     
  1036.     PlotInit = True
  1037.     Cls
  1038.     ForeColor = QBColor(15)
  1039.     FillColor = ForeColor
  1040.     BackColor = QBColor(0)
  1041.     FillStyle = 0' use solid fill
  1042.  
  1043.     ' set index to count number of times to repeat color
  1044.     '   to past maxvalue so that it will be recalculated
  1045.     RepeatIndex = MaxLines + 1
  1046.  
  1047.     'determine initial position of line
  1048.     x1 = Rnd * ScaleWidth
  1049.     x2 = Rnd * ScaleWidth
  1050.     y1 = Rnd * ScaleHeight
  1051.     y2 = Rnd * ScaleHeight
  1052.  
  1053.     'set initial velocity
  1054.     vx1 = 0
  1055.     vx2 = 0
  1056.     vy1 = 0
  1057.     vy2 = 0
  1058.  
  1059.     'set initial acceleration
  1060.     ax1 = 0
  1061.     ax2 = 0
  1062.     ay1 = 0
  1063.     ay2 = 0
  1064.     
  1065.     'find background color
  1066.     'Calculate velocity limits
  1067.     MaxSpeedX = ScaleWidth * 15! / 800
  1068.     MaxSpeedY = ScaleWidth * 15! / 600
  1069.  
  1070.   Else 'reset changes done by previous init
  1071.  
  1072.     ClearScreen
  1073.     FillStyle = 1 'transparent fill
  1074.  
  1075.   End If
  1076.  
  1077.   Else  ' put run code here
  1078.  
  1079.     ' check if time to get a new color
  1080.     If RepeatIndex > RepeatCount Then
  1081.     
  1082.     ' get random fore ground color
  1083.     i = Rnd * 255: If i > 255 Then i = 255
  1084.     j = Rnd * 255: If j > 255 Then j = 255
  1085.     k = Rnd * 255: If k > 255 Then k = 255
  1086.     ForeColor = RGB(i, j, k)
  1087.  
  1088.     ' get random fill color
  1089.     i = Rnd * 255: If i > 255 Then i = 255
  1090.     j = Rnd * 255: If j > 255 Then j = 255
  1091.     k = Rnd * 255: If k > 255 Then k = 255
  1092.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  1093.  
  1094.     RepeatIndex = 1
  1095.     Else
  1096.     RepeatIndex = RepeatIndex + 1
  1097.     End If
  1098.  
  1099.     'Draw new Circle
  1100.     xRadius = Abs(x1 - x2) / 2
  1101.     yRadius = Abs(y1 - y2) / 2
  1102.     If xRadius <> 0 Then
  1103.         Circle ((x1 + x2) / 2, (y1 + y2) / 2), xRadius, , , , yRadius / xRadius
  1104.     End If
  1105.  
  1106.     'Move pointer to next item
  1107.     Pointer = Pointer + 1
  1108.     If Pointer > MaxLines Then
  1109.         Pointer = 1
  1110.     End If
  1111.  
  1112.     'determine new acceleration
  1113.     ax1 = Rnd - .5
  1114.     ax2 = Rnd - .5
  1115.     ay1 = Rnd - .5
  1116.     ay2 = Rnd - .5
  1117.  
  1118.     'calculate new position
  1119.     x1 = x1 + vx1
  1120.     x2 = x2 + vx2
  1121.     y1 = y1 + vy1
  1122.     y2 = y2 + vy2
  1123.  
  1124.     'calculate new velocity
  1125.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1126.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1127.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1128.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1129.  
  1130.     'check if off screen
  1131.     If (x1 > ScaleWidth) Then
  1132.         'change direction
  1133.         vx1 = -Abs(vx1)
  1134.     ElseIf (x1 < 0) Then
  1135.         'change direction
  1136.         vx1 = Abs(vx1)
  1137.     End If
  1138.  
  1139.     If (y1 > ScaleHeight) Then
  1140.         'change direction
  1141.         vy1 = -Abs(vy1)
  1142.     ElseIf (y1 < 0) Then
  1143.         'change direction
  1144.         vy1 = Abs(vy1)
  1145.     End If
  1146.  
  1147.     If (x2 > ScaleWidth) Then
  1148.         'change direction
  1149.         vx2 = -Abs(vx2)
  1150.     ElseIf (x2 < 0) Then
  1151.         'change direction
  1152.         vx2 = Abs(vx2)
  1153.     End If
  1154.  
  1155.     If (y2 > ScaleHeight) Then
  1156.         'change direction
  1157.         vy2 = -Abs(vy2)
  1158.     ElseIf (y2 < 0) Then
  1159.         'change direction
  1160.         vy2 = Abs(vy2)
  1161.     End If
  1162.  
  1163.  
  1164.   End If
  1165.  
  1166.  
  1167. End Sub
  1168.  
  1169. Sub FilledPolygons ()
  1170.  
  1171.   ' draw a randomly moving polygon on the screen
  1172.   ' slightly offset from previous polygon
  1173.  
  1174.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  1175.   Static Sets As Integer
  1176.   
  1177.   ' if first time then initialize
  1178.   If PlotInit = False Then
  1179.     
  1180.     'see if we need to reset changes made from previous init
  1181.     If PlotEnd = False Then
  1182.     
  1183.     'check if saver is permitted to run
  1184.     If CheckIfValidSaver(0) = 0 Then
  1185.       Exit Sub
  1186.     End If
  1187.     
  1188.     PlotInit = True
  1189.     ForeColor = RGB(255, 255, 255)
  1190.     BackColor = RGB(0, 0, 0)
  1191.     FillStyle = 0' use solid fill
  1192.     DrawWidth = 1' use narrow line
  1193.     j = SetPolyFillMode(hDC, 2)' use winding fill mode
  1194.     Cls
  1195.  
  1196.     'set number of corners between 3 and 5
  1197.     Sets = Rnd * 4 + 3
  1198.  
  1199.     'Set array size and clear the elements
  1200.     ReDim Points(Sets) As POINTAPI
  1201.     ReDim vx1sa(Sets) As Single
  1202.     ReDim vy1sa(Sets) As Single
  1203.     ReDim ax1sa(Sets) As Single
  1204.     ReDim ay1sa(Sets) As Single
  1205.     
  1206.     'counter for changing colors, set to overflow
  1207.     RepeatIndex = RepeatCount + 1
  1208.     
  1209.     For j = 1 To Sets
  1210.  
  1211.     'determine initial position of line
  1212.     Points(j).x = Rnd * ScaleWidth
  1213.     Points(j).y = Rnd * ScaleHeight
  1214.  
  1215.     Next j
  1216.     
  1217.     'Calculate velocity limits
  1218.     MaxSpeedX = ScaleWidth * 15! / 800
  1219.     MaxSpeedY = ScaleWidth * 15! / 600
  1220.  
  1221.   Else 'reset changes done by previous init
  1222.  
  1223.     ReDim Points(0) As POINTAPI
  1224.     ReDim vx1sa(0) As Single
  1225.     ReDim vy1sa(0) As Single
  1226.     ReDim ax1sa(0) As Single
  1227.     ReDim ay1sa(0) As Single
  1228.  
  1229.     FillStyle = 1 'transparent fill
  1230.     j = SetPolyFillMode(hDC, 1)' reset to alternate fill mode
  1231.     ClearScreen
  1232.  
  1233.   End If
  1234.  
  1235.   Else  ' put run code here
  1236.  
  1237.  
  1238.     ' check if time to get a new color
  1239.     If RepeatIndex > RepeatCount Then
  1240.     
  1241.     'set fill color
  1242.     i = Rnd * 255: If i > 255 Then i = 255
  1243.     j = Rnd * 255: If j > 255 Then j = 255
  1244.     k = Rnd * 255: If k > 255 Then k = 255
  1245.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  1246.     
  1247.     'set foreground color
  1248.     i = Rnd * 255: If i > 255 Then i = 255
  1249.     j = Rnd * 255: If j > 255 Then j = 255
  1250.     k = Rnd * 255: If k > 255 Then k = 255
  1251.     ForeColor = RGB(i, j, k)
  1252.     
  1253.     RepeatIndex = 1
  1254.     Else
  1255.     RepeatIndex = RepeatIndex + 1
  1256.     End If
  1257.  
  1258.  
  1259.     'Draw polygon
  1260.     j = Polygon(hDC, Points(0), Sets)
  1261.  
  1262.     For j = 1 To Sets
  1263.  
  1264.         'determine new acceleration
  1265.         ax1sa(j) = Rnd - .5
  1266.         ay1sa(j) = Rnd - .5
  1267.         
  1268.         'calculate new position
  1269.         Points(j).x = Points(j).x + vx1sa(j)
  1270.         Points(j).y = Points(j).y + vy1sa(j)
  1271.  
  1272.         'calculate new velocity
  1273.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  1274.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  1275.  
  1276.         'check if off screen
  1277.         If (Points(j).x > ScaleWidth) Then
  1278.         'change direction
  1279.         vx1sa(j) = -Abs(vx1sa(j))
  1280.         ElseIf (Points(j).x < 0) Then
  1281.         'change direction
  1282.         vx1sa(j) = Abs(vx1sa(j))
  1283.         End If
  1284.  
  1285.         If (Points(j).y > ScaleHeight) Then
  1286.         'change direction
  1287.         vy1sa(j) = -Abs(vy1sa(j))
  1288.         ElseIf (Points(j).y < 0) Then
  1289.         'change direction
  1290.         vy1sa(j) = Abs(vy1sa(j))
  1291.         End If
  1292.  
  1293.     Next j
  1294.     
  1295.     End If
  1296.  
  1297.  
  1298. End Sub
  1299.  
  1300. '
  1301. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  1302.     
  1303.     Static KeyState As String * 257
  1304.     Dim LongChar As Long
  1305.     Dim KeyAscii As Integer
  1306.     Static temp$    ' Collects characters each time key is pressed.
  1307.  
  1308.  
  1309.     If Passwd = "" Then
  1310.  
  1311.     LogFile ("KeyDown, Terminating"), 0
  1312.     EndScrnSaveForm         ' End screen blanking
  1313.  
  1314.     Else
  1315.  
  1316.     'refresh system modal in case another process
  1317.     'has grabbed it
  1318.     If TestMode = 0 Then
  1319.         ZOrder 0' make sure form is still on top
  1320.         i = SetSysModalWindow(hWnd)
  1321.     End If
  1322.     
  1323.     'refresh password box
  1324.     PasswordLabel.Visible = False
  1325.     PasswordLabel.Visible = True
  1326.  
  1327.     'convert key to ascii
  1328.     'GetKeyboardStateBystring (KeyState)' get kb state
  1329.     'i = ToAsciiBystring(KeyCode, 0, KeyState, LongChar, 0)
  1330.     'KeyAscii = LongChar Mod 256
  1331.     KeyAscii = MapVirtualKey(KeyCode, 2) ' convert virtual key code to ascii
  1332.  
  1333.     LogFile ("KeyDown, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received, translated to '" + Chr$(KeyAscii) + "' (" + Str$(KeyAscii) + ")"), 0
  1334.  
  1335.     KeyCode = 0' clear key
  1336.  
  1337.     'parse key into password
  1338.     If KeyAscii = 13 Then       ' ENTER key pressed.
  1339.        KeyAscii = 0            ' Prevents Beep after ENTER Key.
  1340.        If temp$ = Passwd Then
  1341.          LogFile ("Password entered, Terminating"), 0
  1342.          EndScrnSaveForm          ' End screen blanking
  1343.        Else
  1344.          temp$ = ""
  1345.          LogFile ("Invalid Password entered, Continuing"), 0
  1346.          PasswordLabel.Caption = "Password Invalid  "
  1347.          Beep  ' Signal user that password failed.
  1348.          Exit Sub
  1349.        End If
  1350.  
  1351.     ElseIf KeyAscii = 8 Then    ' Backspace key pressed.
  1352.        KeyAscii = 0            'character is not passed on
  1353.        If temp$ <> "" Then 'only delete if not empty
  1354.          temp$ = Left$(temp$, Len(temp$) - 1) ' Remove one char.
  1355.        Else
  1356.          Beep
  1357.        End If
  1358.     
  1359.     ElseIf Len(temp$) = NUMCHARS Then      ' Limit size of password.
  1360.        KeyAscii = 0
  1361.        Beep                    ' Signal user that field is full.
  1362.  
  1363.     ElseIf KeyAscii < 32 Then  ' ignore control keys
  1364.        KeyAscii = 0            ' character is not passed on
  1365.  
  1366.     Else 'normal character that we can recognize?
  1367.        temp$ = temp$ + UCase$(Chr$(KeyAscii))    ' Add a character.
  1368.        KeyAscii = 0            'character is not passed on
  1369.     End If
  1370.  
  1371.     PasswordLabel.Caption = "Password>" + String$(Len(temp$), "*")
  1372.  
  1373.     End If
  1374.  
  1375. End Sub
  1376.  
  1377. Sub Form_KeyPress (KeyAscii As Integer)
  1378.  
  1379.     If Passwd <> "" Then
  1380.  
  1381.     'refresh system modal in case another process
  1382.     'has grabbed it
  1383.     If TestMode = 0 Then
  1384.        ZOrder 0' make sure form is still on top
  1385.        i = SetSysModalWindow(hWnd)
  1386.     End If
  1387.  
  1388.        'refresh password box
  1389.        PasswordLabel.Visible = False
  1390.        PasswordLabel.Visible = True
  1391.  
  1392.        LogFile ("KeyPress, '" + Chr$(KeyAscii) + "' received, code(" + Str$(KeyAscii) + ")"), 0
  1393.        KeyAscii = 0 ' trap characters
  1394.  
  1395.     Else
  1396.  
  1397.     LogFile ("KeyPress, Terminating"), 0
  1398.     EndScrnSaveForm            ' End screen blanking
  1399.  
  1400.     End If
  1401.  
  1402. End Sub
  1403.  
  1404. Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
  1405.  
  1406. LogFile ("KeyUp, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received"), 0
  1407.  
  1408. End Sub
  1409.  
  1410. Sub Form_Load ()
  1411.  
  1412.     ' stretch to full screen
  1413.     Move 0, 0, screen.Width, screen.Height
  1414.  
  1415.     TotalNumColors = GetNumberOfColors()'read number colors display can handle
  1416.     LogFile "Display supports " + Str$(TotalNumColors) + " colors", 0
  1417.  
  1418.     KeyPreview = True 'form takes priority on keys
  1419.     
  1420.     'set system modal
  1421.     If TestMode = 0 Then
  1422.       ZOrder 0' make sure form is still on top
  1423.       i = SetSysModalWindow(hWnd) 'make sure can't CTL-ALT-DEL out
  1424.     End If
  1425.  
  1426.     'make mouse invisible
  1427.     If TestMode = 0 Then
  1428.       HideMouse
  1429.     End If
  1430.  
  1431.     'tell windows to disable screen savers
  1432.     i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, False, 0, 0)
  1433.     
  1434.     DrawWidth = 1
  1435.  
  1436.     Randomize
  1437.  
  1438.     MaxPlotType = 21
  1439.     ReadPriorities ' call each Plot type to get its priority
  1440.  
  1441.     ' Initialize variables now
  1442.     'set plot type
  1443.     If StartSaver = 0 Then
  1444.       PlotType = MaxPlotType * Rnd
  1445.     Else
  1446.       PlotType = StartSaver
  1447.     End If
  1448.  
  1449.     If PlotType > MaxPlotType Then PlotType = 1
  1450.  
  1451.     LogFile ("First Saver is " + Str$(PlotType)), 1
  1452.  
  1453.     PlotInit = False
  1454.     PlotEnd = False
  1455.  
  1456.     TimeInterval = 0
  1457.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  1458.  
  1459.     'set tick rate
  1460.     Tick.Interval = 50
  1461.  
  1462.     Repeats = 1 ' number of drawings to make before returning
  1463.  
  1464.     Tick.Enabled = True
  1465.  
  1466. End Sub
  1467.  
  1468. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  1469.  
  1470.     If IsEmpty(MouseX) Or IsEmpty(MouseY) Then
  1471.     MouseX = x
  1472.     MouseY = y
  1473.     LogFile ("First Mouse Movement (" + Str$(x) + "," + Str$(y) + ")"), 0
  1474.     End If
  1475.  
  1476.     '
  1477.     ' Only unblank the screen if the mouse moves quickly
  1478.     ' enough (more than 2 pixels at one time.
  1479.     '
  1480.     If Abs(MouseX - x) > 2 Or Abs(MouseY - y) > 2 Then
  1481.        
  1482.       If Passwd = "" Then ' only exit if no password
  1483.  
  1484.      LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Terminating"), 0
  1485.      LogFile ("Old Pos (" + Str$(MouseX) + "," + Str$(MouseY) + "), Terminating"), 0
  1486.      EndScrnSaveForm          ' End screen blanking
  1487.  
  1488.       Else
  1489.  
  1490.     'refresh system modal in case another process
  1491.     'has grabbed it
  1492.     If TestMode = 0 Then
  1493.         i = SetSysModalWindow(hWnd)
  1494.     End If
  1495.  
  1496.     PasswordLabel.Visible = False
  1497.     PasswordLabel.Visible = True
  1498.  
  1499.       End If
  1500.  
  1501.     End If
  1502.     LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Continuing"), 0
  1503.     MouseX = x                   ' Remember last position
  1504.     MouseY = y
  1505.  
  1506. End Sub
  1507.  
  1508. Sub Form_Paint ()
  1509.     
  1510.     ' stretch to full screen
  1511.     Move 0, 0, screen.Width, screen.Height
  1512.  
  1513. End Sub
  1514.  
  1515. Function GetBrightNonGray () As Long
  1516.  
  1517. ' this function is needed because in 256 color mode
  1518. ' many random colors get mapped to grays
  1519.  
  1520.   Dim i As Long, j As Long, k As Long
  1521.   Dim NewColor As Long
  1522.  
  1523.   Do
  1524.     i = Rnd * 255: If i > 255 Then i = 255
  1525.     j = Rnd * 255: If j > 255 Then j = 255
  1526.     k = Rnd * 255: If k > 255 Then k = 255
  1527.  
  1528.     'LogFile ("GetBrightNonGray testing color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1529.  
  1530.     'get nearest colors
  1531.     NewColor = GetNearestColor(hDC, RGB(i, j, k))
  1532.     i = NewColor And &HFF
  1533.     j = NewColor \ &H100 And &HFF
  1534.     k = NewColor \ &H10000 And &HFF
  1535.  
  1536.     'LogFile ("GetBrightNonGray nearest color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1537.  
  1538.     'make sure color is sufficiently bright, and not too gray
  1539.     Loop Until ((i * i + j * j + k * k) > MinColor) And ((Abs(i - j) > MinDiff) Or (Abs(j - k) > MinDiff))
  1540.  
  1541.   'LogFile ("GetBrightNonGray using color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1542.   GetBrightNonGray = NewColor
  1543.  
  1544. End Function
  1545.  
  1546. Function GetNumberOfColors () As Single
  1547.  
  1548.   Dim i As Integer, j As Integer, k As Integer
  1549.  
  1550.   ' get bits per pixel per plane
  1551.   i = GetDeviceCaps(hDC, BITSPIXEL)
  1552.   ' get number of planes
  1553.   j = GetDeviceCaps(hDC, PLANES)
  1554.   ' get total bits per pixel
  1555.   k = i * j
  1556.   GetNumberOfColors = 2# ^ k
  1557. End Function
  1558.  
  1559. Function GetSize (FileName$) As Integer
  1560.     
  1561.     Dim InLine$
  1562.     Dim Loaded As Integer
  1563.  
  1564.     Open FileName$ For Binary As #1
  1565.  
  1566.     '*****************************************************
  1567.     'read header
  1568.     InLine$ = Input$(26, 1)
  1569.     
  1570.     If Asc(Mid$(InLine$, 1, 1)) <> &H42 Then GoTo errorexit
  1571.     If Asc(Mid$(InLine$, 2, 1)) <> &H4D Then GoTo errorexit
  1572.  
  1573.     PicWidth = Asc(Mid$(InLine$, 19, 1)) + Asc(Mid$(InLine$, 20, 1)) * 256
  1574.     PicHeight = Asc(Mid$(InLine$, 23, 1)) + Asc(Mid$(InLine$, 24, 1)) * 256
  1575.  
  1576.     'Debug.Print SWidth, SHeight
  1577.  
  1578.     Close #1
  1579.  
  1580.     Loaded = 1 'flag good read
  1581.  
  1582.     GoTo regexit
  1583.  
  1584. errorexit: Loaded = 0
  1585. regexit: ' no error exit
  1586.     GetSize = Loaded'return read state
  1587. End Function
  1588.  
  1589. Sub Kalied ()
  1590.   
  1591.   ' have a line and its mirror images trace across the
  1592.   ' screen with multiple previous copies following
  1593.   ' it
  1594.  
  1595.   Dim xRadius As Integer, yRadius As Integer
  1596.   Static OldWidth As Integer, OldHeight As Integer
  1597.   Static OldLeft As Integer, OldTop As Integer
  1598.   Static Discontinuous As Integer
  1599.  
  1600.   ' if first time then initialize
  1601.   If PlotInit = False Then
  1602.     
  1603.    'see if we need to reset changes made from previous init
  1604.    If PlotEnd = False Then
  1605.     
  1606.     'check if saver is permitted to run
  1607.     If CheckIfValidSaver(0) = 0 Then
  1608.       Exit Sub
  1609.     End If
  1610.     
  1611.     PlotInit = True
  1612.     Cls
  1613.     ForeColor = QBColor(15)
  1614.  
  1615.     If Rnd > .5 Then
  1616.       Discontinuous = False
  1617.     Else
  1618.       Discontinuous = True
  1619.     End If
  1620.  
  1621.     'select mirroring method
  1622.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1623.  
  1624.     'Set array size and clear the elements
  1625.     ReDim x1a(MaxLines) As Integer
  1626.     ReDim x2a(MaxLines) As Integer
  1627.     ReDim y1a(MaxLines) As Integer
  1628.     ReDim y2a(MaxLines) As Integer
  1629.  
  1630.     Pointer = 1     ' start with array element 1
  1631.     
  1632.     ' set index to count number of times to repeat color
  1633.     '   to past maxvalue so that it will be recalculated
  1634.     RepeatIndex = MaxLines + 1
  1635.  
  1636.     'save old
  1637.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1638.     OldLeft = Scaleleft: OldTop = Scaletop
  1639.  
  1640.     'change scaleso they are symetrical:
  1641.     ScaleHeight = ScaleWidth
  1642.     Scaleleft = -ScaleHeight / 2
  1643.     Scaletop = Scaleleft
  1644.  
  1645.     'Calculate velocity limits
  1646.     MaxSpeedX = ScaleWidth * 15! / 800
  1647.     MaxSpeedY = ScaleWidth * 15! / 600
  1648.  
  1649.     'determine initial position of line
  1650.     x1 = (Rnd - .5) * ScaleWidth
  1651.     x2 = (Rnd - .5) * ScaleWidth
  1652.     y1 = (Rnd - .5) * ScaleHeight
  1653.     y2 = (Rnd - .5) * ScaleHeight
  1654.  
  1655.     'set initial velocity
  1656.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1657.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1658.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1659.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1660.  
  1661.     'set initial acceleration
  1662.     ax1 = 0
  1663.     ax2 = 0
  1664.     ay1 = 0
  1665.     ay2 = 0
  1666.     
  1667.     'find background color
  1668.     m = QBColor(0)
  1669.  
  1670.     'set tick rate
  1671.     Tick.Interval = 50
  1672.  
  1673.  
  1674.   Else 'reset changes done by previous init
  1675.  
  1676.     'reset tick rate
  1677.     Tick.Interval = 50
  1678.  
  1679.     'zero array sizes
  1680.     ReDim x1a(0) As Integer
  1681.     ReDim x2a(0) As Integer
  1682.     ReDim y1a(0) As Integer
  1683.     ReDim y2a(0) As Integer
  1684.  
  1685.       'reset screen dimensions
  1686.       ScaleWidth = OldWidth
  1687.       ScaleHeight = OldHeight
  1688.       Scaleleft = OldLeft
  1689.       Scaletop = OldTop
  1690.  
  1691.     ClearScreen
  1692.  
  1693.   End If
  1694.  
  1695.   Else  ' put run code here
  1696.  
  1697.  
  1698.     ' check if time to get a new color
  1699.     If RepeatIndex > RepeatCount Then
  1700.     
  1701.     ' get color
  1702.     l = GetBrightNonGray()
  1703.  
  1704.     If Discontinuous = True Then
  1705.  
  1706.       'determine new position of line
  1707.       x1 = (Rnd - .5) * ScaleWidth
  1708.       x2 = (Rnd - .5) * ScaleWidth
  1709.       y1 = (Rnd - .5) * ScaleHeight
  1710.       y2 = (Rnd - .5) * ScaleHeight
  1711.  
  1712.       'set new velocity
  1713.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1714.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1715.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1716.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1717.  
  1718.       'clear acceleration
  1719.       ax1 = 0
  1720.       ax2 = 0
  1721.       ay1 = 0
  1722.       ay2 = 0
  1723.     
  1724.     End If
  1725.  
  1726.     RepeatIndex = 1
  1727.     Else
  1728.     RepeatIndex = RepeatIndex + 1
  1729.     End If
  1730.  
  1731.     'Delete original Lines
  1732.     KaliedPlot Mirror, x1a(Pointer), y1a(Pointer), x2a(Pointer), y2a(Pointer), m
  1733.  
  1734.     'Save New Lines
  1735.     x1a(Pointer) = x1
  1736.     x2a(Pointer) = x2
  1737.     y1a(Pointer) = y1
  1738.     y2a(Pointer) = y2
  1739.  
  1740.     DoEvents
  1741.  
  1742.     'Draw New Lines
  1743.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1744.  
  1745.     'Move pointer to next item
  1746.     Pointer = Pointer + 1
  1747.     If Pointer > MaxLines Then
  1748.         Pointer = 1
  1749.     End If
  1750.  
  1751.     'determine new acceleration
  1752.     ax1 = Rnd - .5
  1753.     ax2 = Rnd - .5
  1754.     ay1 = Rnd - .5
  1755.     ay2 = Rnd - .5
  1756.  
  1757.     'calculate new position
  1758.     x1 = x1 + vx1
  1759.     x2 = x2 + vx2
  1760.     y1 = y1 + vy1
  1761.     y2 = y2 + vy2
  1762.  
  1763.     'calculate new velocity
  1764.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1765.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1766.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1767.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1768.  
  1769.     'check if off screen
  1770.     If (x1 > -Scaleleft) Then
  1771.         'change direction
  1772.         vx1 = -Abs(vx1)
  1773.     ElseIf (x1 < Scaleleft) Then
  1774.         'change direction
  1775.         vx1 = Abs(vx1)
  1776.     End If
  1777.  
  1778.     If (y1 > -Scaletop) Then
  1779.         'change direction
  1780.         vy1 = -Abs(vy1)
  1781.     ElseIf (y1 < Scaletop) Then
  1782.         'change direction
  1783.         vy1 = Abs(vy1)
  1784.     End If
  1785.  
  1786.     If (x2 > -Scaleleft) Then
  1787.         'change direction
  1788.         vx2 = -Abs(vx2)
  1789.     ElseIf (x2 < Scaleleft) Then
  1790.         'change direction
  1791.         vx2 = Abs(vx2)
  1792.     End If
  1793.  
  1794.     If (y2 > -Scaletop) Then
  1795.         'change direction
  1796.         vy2 = -Abs(vy2)
  1797.     ElseIf (y2 < Scaletop) Then
  1798.         'change direction
  1799.         vy2 = Abs(vy2)
  1800.     End If
  1801.  
  1802.     
  1803.     
  1804.     End If
  1805.  
  1806. End Sub
  1807.  
  1808. Sub Kalied2 ()
  1809.   
  1810.   ' have a line and its mirror images trace across the
  1811.   ' screen with all the previous copies left on the screen
  1812.   ' until the maximum is reached and the screen cleared
  1813.  
  1814.   Dim xRadius As Integer, yRadius As Integer
  1815.   Static OldWidth As Integer, OldHeight As Integer
  1816.   Static OldLeft As Integer, OldTop As Integer
  1817.   Static Discontinuous As Integer
  1818.  
  1819.   ' if first time then initialize
  1820.   If PlotInit = False Then
  1821.     
  1822.     'see if we need to reset changes made from previous init
  1823.     If PlotEnd = True Then
  1824.       ScaleWidth = OldWidth
  1825.       ScaleHeight = OldHeight
  1826.       Scaleleft = OldLeft
  1827.       Scaletop = OldTop
  1828.       ClearScreen
  1829.       Exit Sub
  1830.     End If
  1831.     
  1832.     'check if saver is permitted to run
  1833.     If CheckIfValidSaver(0) = 0 Then
  1834.       Exit Sub
  1835.     End If
  1836.     
  1837.     PlotInit = True
  1838.     Cls
  1839.     ForeColor = QBColor(15)
  1840.  
  1841.     If Rnd > .5 Then
  1842.       Discontinuous = False
  1843.     Else
  1844.       Discontinuous = True
  1845.     End If
  1846.  
  1847.     'select mirroring method
  1848.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1849.  
  1850.     Pointer = 1     ' set lines on screen to one
  1851.     
  1852.     ' set index to count number of times to repeat color
  1853.     '   to past maxvalue so that it will be recalculated
  1854.     RepeatIndex = MaxLines + 1
  1855.  
  1856.     'save old
  1857.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1858.     OldLeft = Scaleleft: OldTop = Scaletop
  1859.  
  1860.     'change scaleso they are symetrical:
  1861.     ScaleHeight = ScaleWidth
  1862.     Scaleleft = -ScaleHeight / 2
  1863.     Scaletop = Scaleleft
  1864.  
  1865.     'determine initial position of line
  1866.     x1 = (Rnd - .5) * ScaleWidth
  1867.     x2 = (Rnd - .5) * ScaleWidth
  1868.     y1 = (Rnd - .5) * ScaleHeight
  1869.     y2 = (Rnd - .5) * ScaleHeight
  1870.  
  1871.     'set initial velocity
  1872.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1873.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1874.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1875.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1876.  
  1877.     'set initial acceleration
  1878.     ax1 = 0
  1879.     ax2 = 0
  1880.     ay1 = 0
  1881.     ay2 = 0
  1882.     
  1883.     'find background color
  1884.     m = QBColor(0)
  1885.  
  1886.     'Calculate velocity limits
  1887.     MaxSpeedX = ScaleWidth * 15! / 800
  1888.     MaxSpeedY = ScaleWidth * 15! / 600
  1889.  
  1890.   Else  ' put run code here
  1891.  
  1892.  
  1893.     ' check if time to get a new color
  1894.     If RepeatIndex > RepeatCount Then
  1895.     
  1896.     ' get color
  1897.     l = GetBrightNonGray()
  1898.  
  1899.     If Discontinuous = True Then
  1900.  
  1901.       'determine new position of line
  1902.       x1 = (Rnd - .5) * ScaleWidth
  1903.       x2 = (Rnd - .5) * ScaleWidth
  1904.       y1 = (Rnd - .5) * ScaleHeight
  1905.       y2 = (Rnd - .5) * ScaleHeight
  1906.  
  1907.       'set new velocity
  1908.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1909.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1910.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1911.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1912.  
  1913.       'clear acceleration
  1914.       ax1 = 0
  1915.       ax2 = 0
  1916.       ay1 = 0
  1917.       ay2 = 0
  1918.     
  1919.     End If
  1920.  
  1921.     RepeatIndex = 1
  1922.     Else
  1923.     RepeatIndex = RepeatIndex + 1
  1924.     End If
  1925.  
  1926.     'Draw New Lines
  1927.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1928.  
  1929.     ' count total lines on screen
  1930.     Pointer = Pointer + 1
  1931.     If Pointer > MaxCums Then
  1932.         'when maximum reached then clear
  1933.         Cls
  1934.         Pointer = 1
  1935.     End If
  1936.  
  1937.     'determine new acceleration
  1938.     ax1 = Rnd - .5
  1939.     ax2 = Rnd - .5
  1940.     ay1 = Rnd - .5
  1941.     ay2 = Rnd - .5
  1942.  
  1943.     'calculate new position
  1944.     x1 = x1 + vx1
  1945.     x2 = x2 + vx2
  1946.     y1 = y1 + vy1
  1947.     y2 = y2 + vy2
  1948.  
  1949.     'calculate new velocity
  1950.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1951.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1952.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1953.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1954.  
  1955.     'check if off screen
  1956.     If (x1 > -Scaleleft) Then
  1957.         'change direction
  1958.         vx1 = -Abs(vx1)
  1959.     ElseIf (x1 < Scaleleft) Then
  1960.         'change direction
  1961.         vx1 = Abs(vx1)
  1962.     End If
  1963.  
  1964.     If (y1 > -Scaletop) Then
  1965.         'change direction
  1966.         vy1 = -Abs(vy1)
  1967.     ElseIf (y1 < Scaletop) Then
  1968.         'change direction
  1969.         vy1 = Abs(vy1)
  1970.     End If
  1971.  
  1972.     If (x2 > -Scaleleft) Then
  1973.         'change direction
  1974.         vx2 = -Abs(vx2)
  1975.     ElseIf (x2 < Scaleleft) Then
  1976.         'change direction
  1977.         vx2 = Abs(vx2)
  1978.     End If
  1979.  
  1980.     If (y2 > -Scaletop) Then
  1981.         'change direction
  1982.         vy2 = -Abs(vy2)
  1983.     ElseIf (y2 < Scaletop) Then
  1984.         'change direction
  1985.         vy2 = Abs(vy2)
  1986.     End If
  1987.  
  1988.     
  1989.     End If
  1990.  
  1991.  
  1992. End Sub
  1993.  
  1994. Sub KaliedPlot (MirrorMode As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Color As Long)
  1995.  
  1996. 'warning -- recursive subroutine
  1997.  
  1998.   Dim xm1 As Integer, ym1 As Integer, xm2 As Integer, ym2 As Integer
  1999.  
  2000.     Select Case MirrorMode
  2001.     Case 1: 'mirror on x and y axis
  2002.         Line (x1, y1)-(x2, y2), Color
  2003.         Line (-x1, y1)-(-x2, y2), Color
  2004.         Line (x1, -y1)-(x2, -y2), Color
  2005.         Line (-x1, -y1)-(-x2, -y2), Color
  2006.  
  2007.     Case 2: 'mirror on Y axis
  2008.         Line (x1, y1)-(x2, y2), Color
  2009.         Line (-x1, y1)-(-x2, y2), Color
  2010.  
  2011.     Case 3: 'mirror around center point
  2012.         Line (x1, y1)-(x2, y2), Color
  2013.         Line (-x1, -y1)-(-x2, -y2), Color
  2014.  
  2015.     Case 4: 'mirror around center point and diagonally
  2016.         Line (x1, y1)-(x2, y2), Color
  2017.         Line (-x1, -y1)-(-x2, -y2), Color
  2018.  
  2019.         'mirror diagonally
  2020.         xm1 = y1
  2021.         ym1 = x1
  2022.         xm2 = y2
  2023.         ym2 = x2
  2024.         Line (-xm1, ym1)-(-xm2, ym2), Color
  2025.         Line (xm1, -ym1)-(xm2, -ym2), Color
  2026.  
  2027.     Case 5: 'mirror on x and y axis and diagonally
  2028.         Line (x1, y1)-(x2, y2), Color
  2029.         Line (-x1, y1)-(-x2, y2), Color
  2030.         Line (x1, -y1)-(x2, -y2), Color
  2031.         Line (-x1, -y1)-(-x2, -y2), Color
  2032.  
  2033.         'mirror diagonally
  2034.         xm1 = y1
  2035.         ym1 = x1
  2036.         xm2 = y2
  2037.         ym2 = x2
  2038.         Line (xm1, ym1)-(xm2, ym2), Color
  2039.         Line (-xm1, ym1)-(-xm2, ym2), Color
  2040.         Line (xm1, -ym1)-(xm2, -ym2), Color
  2041.         Line (-xm1, -ym1)-(-xm2, -ym2), Color
  2042.  
  2043.     Case 6: 'mirror around center point and diagonally
  2044.         'and then shift 45 degrees and repeat
  2045.         KaliedPlot 4, x1, y1, x2, y2, Color
  2046.  
  2047.         'shift 45 degrees, formula
  2048.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2049.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2050.         xm1 = x1 * Cos45 - y1 * Sin45
  2051.         ym1 = y1 * Cos45 + x1 * Sin45
  2052.         xm2 = x2 * Cos45 - y2 * Sin45
  2053.         ym2 = y2 * Cos45 + x2 * Sin45
  2054.  
  2055.         KaliedPlot 4, xm1, ym1, xm2, ym2, Color
  2056.  
  2057.     Case 7: 'mirror on x and y axis and diagonally
  2058.         'and then shift 45 degrees and repeat
  2059.         KaliedPlot 5, x1, y1, x2, y2, Color
  2060.  
  2061.         'shift 45 degrees, formula
  2062.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2063.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2064.         xm1 = x1 * Cos45 - y1 * Sin45
  2065.         ym1 = y1 * Cos45 + x1 * Sin45
  2066.         xm2 = x2 * Cos45 - y2 * Sin45
  2067.         ym2 = y2 * Cos45 + x2 * Sin45
  2068.  
  2069.         KaliedPlot 5, xm1, ym1, xm2, ym2, Color
  2070.  
  2071.     Case 8: 'mirror around center point and diagonally
  2072.         'and then shift 45 degrees and repeat
  2073.         'and then shift 22.5 and repeat the above
  2074.         KaliedPlot 6, x1, y1, x2, y2, Color
  2075.  
  2076.         'shift 22.5 degrees, formula
  2077.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2078.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2079.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  2080.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  2081.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  2082.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  2083.  
  2084.         KaliedPlot 6, xm1, ym1, xm2, ym2, Color
  2085.  
  2086.     Case 9: 'mirror on x and y axis and diagonally
  2087.         'and then shift 45 degrees and repeat
  2088.         'and then shift 22.5 and repeat the above
  2089.         KaliedPlot 7, x1, y1, x2, y2, Color
  2090.  
  2091.         'shift 22.5 degrees, formula
  2092.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2093.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2094.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  2095.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  2096.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  2097.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  2098.  
  2099.         KaliedPlot 7, xm1, ym1, xm2, ym2, Color
  2100.  
  2101.  
  2102.     Case 10: 'mirror around center point and diagonally
  2103.         'and then shift 45 degrees and repeat
  2104.         'and then shift 22.5 and repeat the above
  2105.         'and then shift 11.25 and repeat the above
  2106.         KaliedPlot 8, x1, y1, x2, y2, Color
  2107.  
  2108.         'shift 22.5 degrees, formula
  2109.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2110.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2111.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  2112.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  2113.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  2114.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  2115.  
  2116.         KaliedPlot 8, xm1, ym1, xm2, ym2, Color
  2117.  
  2118.     Case 11: 'mirror on x and y axis and diagonally
  2119.         'and then shift 45 degrees and repeat
  2120.         'and then shift 22.5 and repeat the above
  2121.         'and then shift 11.25 and repeat the above
  2122.         KaliedPlot 9, x1, y1, x2, y2, Color
  2123.  
  2124.         'shift 22.5 degrees, formula
  2125.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  2126.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  2127.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  2128.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  2129.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  2130.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  2131.  
  2132.         KaliedPlot 9, xm1, ym1, xm2, ym2, Color
  2133.  
  2134.     Case Else: MirrorMode = 1' if invalid value set, then change
  2135.     
  2136.     End Select
  2137.  
  2138.  
  2139. End Sub
  2140.  
  2141. Sub Lines ()
  2142.  
  2143.   ' have a random number of lines trace across the
  2144.   ' screen with multiple previous copies following
  2145.   ' them
  2146.  
  2147.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2148.   Dim il As Long, jl As Long, kl As Long
  2149.   Static Sets As Integer
  2150.   
  2151.   ' if first time then initialize
  2152.   If PlotInit = False Then
  2153.     
  2154.    'see if we need to reset changes made from previous init
  2155.    If PlotEnd = False Then
  2156.     
  2157.     'check if saver is permitted to run
  2158.     If CheckIfValidSaver(0) = 0 Then
  2159.       Exit Sub
  2160.     End If
  2161.     
  2162.     PlotInit = True
  2163.     Cls
  2164.     ForeColor = QBColor(15)
  2165.  
  2166.     'set number of sets between 1 and 4
  2167.     Sets = Rnd * 3 + 1
  2168.  
  2169.     'Set array size and clear the elements
  2170.     ReDim x1da(MaxLines, Sets) As Integer
  2171.     ReDim x2da(MaxLines, Sets) As Integer
  2172.     ReDim y1da(MaxLines, Sets) As Integer
  2173.     ReDim y2da(MaxLines, Sets) As Integer
  2174.     ReDim x1sa(Sets) As Single
  2175.     ReDim x2sa(Sets) As Single
  2176.     ReDim y1sa(Sets) As Single
  2177.     ReDim y2sa(Sets) As Single
  2178.     ReDim vx1sa(Sets) As Single
  2179.     ReDim vx2sa(Sets) As Single
  2180.     ReDim vy1sa(Sets) As Single
  2181.     ReDim vy2sa(Sets) As Single
  2182.     ReDim ax1sa(Sets) As Single
  2183.     ReDim ax2sa(Sets) As Single
  2184.     ReDim ay1sa(Sets) As Single
  2185.     ReDim ay2sa(Sets) As Single
  2186.     ReDim Colors(Sets) As Long
  2187.     
  2188.     Pointer = 1     ' start with array element 1
  2189.     
  2190.     ' set index to count number of times to repeat color
  2191.     '   to past maxvalue so that it will be recalculated
  2192.     RepeatIndex = MaxLines + 1
  2193.  
  2194.     For j = 1 To Sets
  2195.  
  2196.     'determine initial position of line
  2197.     x1sa(j) = Rnd * ScaleWidth
  2198.     x2sa(j) = Rnd * ScaleWidth
  2199.     y1sa(j) = Rnd * ScaleHeight
  2200.     y2sa(j) = Rnd * ScaleHeight
  2201.  
  2202.     Next j
  2203.     
  2204.     'find background color
  2205.     m = QBColor(0)
  2206.  
  2207.     'Calculate velocity limits
  2208.     MaxSpeedX = ScaleWidth * 15! / 800
  2209.     MaxSpeedY = ScaleWidth * 15! / 600
  2210.  
  2211.  
  2212.   Else 'reset changes done by previous init
  2213.  
  2214.     'Set array size and clear the elements
  2215.     ReDim x1da(0, 0) As Integer
  2216.     ReDim x2da(0, 0) As Integer
  2217.     ReDim y1da(0, 0) As Integer
  2218.     ReDim y2da(0, 0) As Integer
  2219.     ReDim x1sa(0) As Single
  2220.     ReDim x2sa(0) As Single
  2221.     ReDim y1sa(0) As Single
  2222.     ReDim y2sa(0) As Single
  2223.     ReDim vx1sa(0) As Single
  2224.     ReDim vx2sa(0) As Single
  2225.     ReDim vy1sa(0) As Single
  2226.     ReDim vy2sa(0) As Single
  2227.     ReDim ax1sa(0) As Single
  2228.     ReDim ax2sa(0) As Single
  2229.     ReDim ay1sa(0) As Single
  2230.     ReDim ay2sa(0) As Single
  2231.     ReDim Colors(0) As Long
  2232.  
  2233.     ClearScreen
  2234.     
  2235.   End If
  2236.  
  2237.   Else  ' put run code here
  2238.  
  2239.  
  2240.     ' check if time to get a new color
  2241.     If RepeatIndex > RepeatCount Then
  2242.     
  2243.     ' get colors
  2244.     For ii = 1 To Sets
  2245.       Colors(ii) = GetBrightNonGray()
  2246.     Next ii
  2247.  
  2248.     RepeatIndex = 1
  2249.     Else
  2250.     RepeatIndex = RepeatIndex + 1
  2251.     End If
  2252.  
  2253.     'Delete original Lines
  2254.     For j = 1 To Sets
  2255.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  2256.     Next j
  2257.  
  2258.     For j = 1 To Sets
  2259.  
  2260.         'Save New Lines
  2261.         x1da(Pointer, j) = x1sa(j)
  2262.         x2da(Pointer, j) = x2sa(j)
  2263.         y1da(Pointer, j) = y1sa(j)
  2264.         y2da(Pointer, j) = y2sa(j)
  2265.  
  2266.         'Draw new Line
  2267.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  2268.  
  2269.     Next j
  2270.  
  2271.     'Move pointer to next item
  2272.     Pointer = Pointer + 1
  2273.     If Pointer > MaxLines Then
  2274.         Pointer = 1
  2275.     End If
  2276.  
  2277.     For j = 1 To Sets
  2278.  
  2279.         'determine new acceleration
  2280.         ax1sa(j) = Rnd - .5
  2281.         ax2sa(j) = Rnd - .5
  2282.         ay1sa(j) = Rnd - .5
  2283.         ay2sa(j) = Rnd - .5
  2284.  
  2285.         'calculate new position
  2286.         x1sa(j) = x1sa(j) + vx1sa(j)
  2287.         x2sa(j) = x2sa(j) + vx2sa(j)
  2288.         y1sa(j) = y1sa(j) + vy1sa(j)
  2289.         y2sa(j) = y2sa(j) + vy2sa(j)
  2290.  
  2291.         'calculate new velocity
  2292.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2293.         vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  2294.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2295.         vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  2296.  
  2297.         'check if off screen
  2298.         If (x1sa(j) > ScaleWidth) Then
  2299.         'change direction
  2300.         vx1sa(j) = -Abs(vx1sa(j))
  2301.         ElseIf (x1sa(j) < 0) Then
  2302.         'change direction
  2303.         vx1sa(j) = Abs(vx1sa(j))
  2304.         End If
  2305.  
  2306.         If (y1sa(j) > ScaleHeight) Then
  2307.         'change direction
  2308.         vy1sa(j) = -Abs(vy1sa(j))
  2309.         ElseIf (y1sa(j) < 0) Then
  2310.         'change direction
  2311.         vy1sa(j) = Abs(vy1sa(j))
  2312.         End If
  2313.  
  2314.         If (x2sa(j) > ScaleWidth) Then
  2315.         'change direction
  2316.         vx2sa(j) = -Abs(vx2sa(j))
  2317.         ElseIf (x2sa(j) < 0) Then
  2318.         'change direction
  2319.         vx2sa(j) = Abs(vx2sa(j))
  2320.         End If
  2321.  
  2322.         If (y2sa(j) > ScaleHeight) Then
  2323.         'change direction
  2324.         vy2sa(j) = -Abs(vy2sa(j))
  2325.         ElseIf (y2sa(j) < 0) Then
  2326.         'change direction
  2327.         vy2sa(j) = Abs(vy2sa(j))
  2328.         End If
  2329.  
  2330.     Next j
  2331.     
  2332.     
  2333.   End If
  2334.  
  2335. End Sub
  2336.  
  2337. Function LoadSlide (File As String, ShowPic As Integer) As Integer
  2338.  'loads picture to screen, if gif file extension, then
  2339.  'save to dib bitmap, returns zero on failure
  2340.  
  2341.   Dim RetVal As Integer, i As Integer, l As Long
  2342.   Dim Header As Long, DataBits As Long
  2343.   Dim TempName As String
  2344.  
  2345.   RetVal = 1
  2346.  
  2347.   LogFile "Showing file " + File, 1
  2348.  
  2349.   If InStr(UCase$(File), ".GIF") = 0 Then
  2350.  
  2351.     ' if not gif file, then bitmap
  2352.     If ShowPic Then
  2353.       On Error GoTo LoadSlide_Error
  2354.       picture = LoadPicture(File)
  2355.       On Error GoTo 0
  2356.     End If
  2357.  
  2358.     'get dimensions of bitmap
  2359.     If GetSize(File) = 0 Then RetVal = 0
  2360.  
  2361.   Else ' convert gif to DIB
  2362.  
  2363.     l = ManyGifLoad(File, PicWidth, PicHeight)'load gif
  2364.     If l <= 0 Then
  2365.       LogFile "Could not read GIF file " + File, 1
  2366.       RetVal = 0
  2367.     Else
  2368.  
  2369.       'where to store converted file
  2370.       TempName = RTrim$(BitmapsDir) + "\tmprary.dib"
  2371.       i = ManyDIBWrite(TempName)
  2372.       If i <> 0 Then 'check for error
  2373.     LogFile "Could not write GIF file " + TempName, 1
  2374.     RetVal = 0
  2375.       Else
  2376.     If ShowPic Then
  2377.       On Error GoTo LoadSlide_Error
  2378.       picture = LoadPicture(TempName)
  2379.       On Error GoTo 0
  2380.     End If
  2381.  
  2382.       End If
  2383.  
  2384.     End If
  2385.  
  2386.   End If
  2387.  
  2388.   LoadSlide = RetVal
  2389.   Exit Function
  2390.  
  2391. LoadSlide_Error:
  2392.   'could not load file, out of memory?
  2393.   On Error GoTo 0
  2394.   RetVal = 0
  2395.   LogFile ("Could not load file " + File), 1
  2396.   Resume Next
  2397.  
  2398. End Function
  2399.  
  2400. Function LoadSlideAndTile (File As String) As Integer
  2401. ' returns zero on error
  2402.  
  2403.   Dim i As Integer, RetVal As Integer
  2404.  
  2405.   If File = "" Then
  2406.     RetVal = 0
  2407.   Else
  2408.  
  2409.     i = LoadSlide(File, 1)'put file on display
  2410.  
  2411.     If i = 0 Then 'check if could not load
  2412.       RetVal = 0
  2413.     Else
  2414.       Replicate
  2415.       RetVal = 1
  2416.     End If
  2417.   End If
  2418.  
  2419.   LoadSlideAndTile = RetVal
  2420.  
  2421. End Function
  2422.  
  2423. Sub MultiSpiros ()
  2424.  
  2425.   'Do spirograph like figures
  2426.  
  2427.   'reserve memory
  2428.   Const Deg2Pi = PI / 180
  2429.   Static MaxRad As Integer'maximum radius for circles
  2430.   Const MaxNodes = 35'maximum number of nodes on spiro
  2431.   Dim Nodes As Integer
  2432.   Const MaxRpts = 7'max times to go around circle
  2433.   Dim Rpts As Integer
  2434.   Const PlotPoints = 1'number of points to plot each time
  2435.   Const ClearCount = 3'number on screen before clearing
  2436.   Static PlotAngleIncr As Single
  2437.   Static PlotEndAngle As Single
  2438.   Static PlotAngle As Single
  2439.   Static SinIncr As Single
  2440.   Static SinAngle As Single
  2441.   Static Xcenter As Integer
  2442.   Static Ycenter As Integer
  2443.   Static Xincr As Integer
  2444.   Static Yincr As Integer
  2445.   Const MaxSpiro = 8' maximum number of simultaneous spiros
  2446.   Static SpiroCnt As Integer
  2447.   Static Rad1 As Integer
  2448.   Static Rad2 As Integer
  2449.   Dim r As Single
  2450.   Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
  2451.   Dim il As Long, jl As Long, kl As Long
  2452.  
  2453.   ' if first time then initialize
  2454.   If PlotInit = False Then
  2455.     
  2456.     'see if we need to reset changes made from previous init
  2457.     If PlotEnd = False Then
  2458.     
  2459.     'check if saver is permitted to run
  2460.     If CheckIfValidSaver(0) = 0 Then
  2461.       Exit Sub
  2462.     End If
  2463.     
  2464.       PlotInit = True
  2465.       ForeColor = RGB(255, 255, 255)
  2466.       BackColor = RGB(0, 0, 0)
  2467.       Cls
  2468.  
  2469.      'initialize variables used
  2470.      PlotEndAngle = 0
  2471.      PlotAngle = 10
  2472.      MaxRad = ScaleHeight / 3'maximum radius for circles
  2473.      Pointer = 0
  2474.  
  2475.     Else 'reset changes done by previous init
  2476.  
  2477.       DrawWidth = 1' use narrow line
  2478.  
  2479.       ClearScreen
  2480.  
  2481.     End If
  2482.  
  2483.   Else  ' put run code here
  2484.  
  2485.    Do
  2486.  
  2487.     ' check if time to do new spiro
  2488.     If PlotAngle > PlotEndAngle Then
  2489.     
  2490.     'set foreground color
  2491.     ForeColor = GetBrightNonGray()
  2492.  
  2493.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  2494.     Rpts = Rnd * MaxRpts + .5
  2495.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  2496.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  2497.     Nodes = Rnd * MaxNodes + .5
  2498.     SinIncr = PlotAngleIncr * Nodes / Rpts
  2499.     SinAngle = 0
  2500.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  2501.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  2502.  
  2503.     'get location of first
  2504.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2505.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2506.  
  2507.     'get location of last
  2508.     i = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2509.     j = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2510.  
  2511.     'get number
  2512.     SpiroCnt = (MaxSpiro - 2) * Rnd + 2' maximum number of simultaneous spiros
  2513.  
  2514.     'calculate increment
  2515.     Xincr = (i - Xcenter) / (SpiroCnt - 1)
  2516.     Yincr = (j - Ycenter) / (SpiroCnt - 1)
  2517.  
  2518.     DrawWidth = 1 + 2 * Rnd ' set line width
  2519.  
  2520.     GoSub 3000 'calculate x1 and y1
  2521.  
  2522.     Delay 2'pause before clearing screen
  2523.     Cls
  2524.     
  2525.     End If
  2526.  
  2527.     For i = 1 To PlotPoints
  2528.  
  2529.       GoSub 3000 'calculate x1 and y1
  2530.  
  2531.       k = x1: l = y1: m = LastX: n = LastY
  2532.  
  2533.       'plot each spiro
  2534.       For j = 1 To SpiroCnt
  2535.  
  2536.     'draw line
  2537.     Line (m, n)-(k, l)
  2538.  
  2539.     'get location for next
  2540.     k = k + Xincr: l = l + Yincr
  2541.     m = m + Xincr: n = n + Yincr
  2542.  
  2543.       Next j
  2544.  
  2545.     Next i
  2546.     
  2547.     DoEvents
  2548.  
  2549.     CurrentTime = Timer
  2550.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  2551.  
  2552.    Loop
  2553.  
  2554.   End If
  2555.  
  2556.   Exit Sub
  2557.  
  2558. 3000 'calculate new point on screen
  2559.   LastX = x1: LastY = y1
  2560.   r = Rad1 + Rad2 * Sin(SinAngle)
  2561.   x1 = r * Cos(PlotAngle) + Xcenter
  2562.   y1 = r * Sin(PlotAngle) + Ycenter
  2563.   SinAngle = SinAngle + SinIncr
  2564.   PlotAngle = PlotAngle + PlotAngleIncr
  2565.  
  2566.   Return
  2567.  
  2568.  
  2569. End Sub
  2570.  
  2571. Sub NextSelection ()
  2572.  
  2573. Dim i As Integer
  2574. Dim Level As Single
  2575.  
  2576. If RandomFlag <> 0 Then
  2577.   ' pick a new selection but not the same as the last
  2578.   Do
  2579.     'i = Int(Rnd * MaxPlotType) + 1'choose next one at random
  2580.     Level = Rnd * TotalPriority' get random proportion of TP
  2581.  
  2582.     'now search array to see which saver this prop. falls into
  2583.     i = 1
  2584.     While (PriorityBreakPoints(i) <= Level)
  2585.       i = i + 1
  2586.     Wend
  2587.     'Debug.Print i, Level, TotalPriority
  2588.  
  2589.     If (i > MaxPlotType) Or (i < 1) Then i = PlotType'flag to try again
  2590.   Loop While (i = PlotType)
  2591.   PlotType = i
  2592.     
  2593. Else
  2594.   PlotType = PlotType + 1
  2595. End If
  2596.  
  2597. LogFile ("Next Saver is" + Str$(PlotType)), 1
  2598.  
  2599. End Sub
  2600.  
  2601. Sub Patch ()
  2602.  
  2603.   ' copy blocks of original screen to random spots
  2604.  
  2605.   ' if first time then initialize
  2606.   If PlotInit = False Then
  2607.     
  2608.    'see if we need to reset changes made from previous init
  2609.    If PlotEnd = False Then
  2610.     
  2611.     'check if saver is permitted to run
  2612.     If CheckIfValidSaver(1) = 0 Then
  2613.       Exit Sub
  2614.     End If
  2615.     
  2616.     ' set tick rate down
  2617.     Tick.Interval = 250
  2618.  
  2619.     ' start with original screen
  2620.     picture = original.Image
  2621.     
  2622.     PlotInit = True
  2623.  
  2624.     i = Int(Rnd * 2#) 'if i=0 then alternate reverse copy
  2625.  
  2626.   Else 'reset changes done by previous init
  2627.  
  2628.     ClearScreen
  2629.     
  2630.     'reset tick rate
  2631.     Tick.Interval = 50
  2632.  
  2633.   End If
  2634.  
  2635.   Else  ' put run code here
  2636.  
  2637.     BoxHeight = Rnd * ScaleHeight / 2.5
  2638.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  2639.  
  2640.     ' get random locations
  2641.     x1 = Rnd * ScaleWidth
  2642.     y1 = Rnd * ScaleHeight
  2643.     x2 = Rnd * ScaleWidth
  2644.     y2 = Rnd * ScaleHeight
  2645.  
  2646.     'make sure room in destination and source blocks
  2647.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  2648.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  2649.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  2650.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  2651.  
  2652.     'BitBlt Box from x2,y2 to x1,y1
  2653.     DC = original.hDC
  2654.     If i = 0 And Rnd < .5 Then
  2655.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &H330008 'not source copy
  2656.     Else
  2657.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020 'source copy
  2658.     End If
  2659.     
  2660.   End If
  2661.  
  2662. End Sub
  2663.  
  2664. Sub Polygons ()
  2665.  
  2666.   ' draw a randomly moving polygon on the screen
  2667.   ' with multiple previous copies following it
  2668.  
  2669.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2670.   Dim il As Long, jl As Long, kl As Long
  2671.   Static Sets As Integer
  2672.   
  2673.   ' if first time then initialize
  2674.   If PlotInit = False Then
  2675.     
  2676.     'see if we need to reset changes made from previous init
  2677.     If PlotEnd = False Then
  2678.     
  2679.     'check if saver is permitted to run
  2680.     If CheckIfValidSaver(0) = 0 Then
  2681.       Exit Sub
  2682.     End If
  2683.     
  2684.     PlotInit = True
  2685.     Cls
  2686.     ForeColor = QBColor(15)
  2687.  
  2688.     'set number of sets between 3 and 5
  2689.     Sets = Rnd * 2 + 3
  2690.  
  2691.     'Set array size and clear the elements
  2692.     ReDim x1da(MaxLines, Sets) As Integer
  2693.     ReDim y1da(MaxLines, Sets) As Integer
  2694.     ReDim x1sa(Sets) As Single
  2695.     ReDim y1sa(Sets) As Single
  2696.     ReDim vx1sa(Sets) As Single
  2697.     ReDim vy1sa(Sets) As Single
  2698.     ReDim ax1sa(Sets) As Single
  2699.     ReDim ay1sa(Sets) As Single
  2700.     
  2701.     Pointer = 1     ' start with array element 1
  2702.     
  2703.     ' set index to count number of times to repeat color
  2704.     '   to past maxvalue so that it will be recalculated
  2705.     RepeatIndex = MaxLines + 1
  2706.  
  2707.     For j = 1 To Sets
  2708.  
  2709.     'determine initial position of line
  2710.     x1sa(j) = Rnd * ScaleWidth
  2711.     y1sa(j) = Rnd * ScaleHeight
  2712.  
  2713.     Next j
  2714.     
  2715.     'find background color
  2716.     m = QBColor(0)
  2717.  
  2718.     'Calculate velocity limits
  2719.     MaxSpeedX = ScaleWidth * 15! / 800
  2720.     MaxSpeedY = ScaleWidth * 15! / 600
  2721.  
  2722.  
  2723.   Else 'reset changes done by previous init
  2724.  
  2725.     'Set array size and clear the elements
  2726.     ReDim x1da(0, 0) As Integer
  2727.     ReDim y1da(0, 0) As Integer
  2728.     ReDim x1sa(0) As Single
  2729.     ReDim y1sa(0) As Single
  2730.     ReDim vx1sa(0) As Single
  2731.     ReDim vy1sa(0) As Single
  2732.     ReDim ax1sa(0) As Single
  2733.     ReDim ay1sa(0) As Single
  2734.  
  2735.     ClearScreen
  2736.  
  2737.   End If
  2738.  
  2739.   Else  ' put run code here
  2740.  
  2741.  
  2742.     ' check if time to get a new color
  2743.     If RepeatIndex > RepeatCount Then
  2744.     
  2745.     ' get colors
  2746.     l = GetBrightNonGray()
  2747.     
  2748.     RepeatIndex = 1
  2749.     Else
  2750.     RepeatIndex = RepeatIndex + 1
  2751.     End If
  2752.  
  2753.     'Delete original Lines
  2754.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  2755.     For j = 3 To Sets
  2756.         Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  2757.     Next j
  2758.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  2759.  
  2760.     For j = 1 To Sets
  2761.  
  2762.         'Save New Lines
  2763.         x1da(Pointer, j) = x1sa(j)
  2764.         y1da(Pointer, j) = y1sa(j)
  2765.  
  2766.     Next j
  2767.  
  2768.     'Draw New Lines
  2769.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  2770.     For j = 3 To Sets
  2771.         Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  2772.     Next j
  2773.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  2774.  
  2775.  
  2776.     'Move pointer to next item
  2777.     Pointer = Pointer + 1
  2778.     If Pointer > MaxLines Then
  2779.         Pointer = 1
  2780.     End If
  2781.  
  2782.     For j = 1 To Sets
  2783.  
  2784.         'determine new acceleration
  2785.         ax1sa(j) = Rnd - .5
  2786.         ay1sa(j) = Rnd - .5
  2787.         
  2788.         'calculate new position
  2789.         x1sa(j) = x1sa(j) + vx1sa(j)
  2790.         y1sa(j) = y1sa(j) + vy1sa(j)
  2791.  
  2792.         'calculate new velocity
  2793.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2794.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2795.  
  2796.         'check if off screen
  2797.         If (x1sa(j) > ScaleWidth) Then
  2798.         'change direction
  2799.         vx1sa(j) = -Abs(vx1sa(j))
  2800.         ElseIf (x1sa(j) < 0) Then
  2801.         'change direction
  2802.         vx1sa(j) = Abs(vx1sa(j))
  2803.         End If
  2804.  
  2805.         If (y1sa(j) > ScaleHeight) Then
  2806.         'change direction
  2807.         vy1sa(j) = -Abs(vy1sa(j))
  2808.         ElseIf (y1sa(j) < 0) Then
  2809.         'change direction
  2810.         vy1sa(j) = Abs(vy1sa(j))
  2811.         End If
  2812.  
  2813.     Next j
  2814.     
  2815.     End If
  2816.  
  2817. End Sub
  2818.  
  2819. Sub Puzzle ()
  2820.  
  2821.   'scramble screen by shifting one column or row at a time
  2822.   
  2823.   Dim tempx As Integer, tempy As Integer
  2824.   Dim x As Integer, y As Integer
  2825.  
  2826.   ' if first time then initialize
  2827.   If PlotInit = False Then
  2828.     
  2829.     'see if we need to reset changes made from previous init
  2830.     If PlotEnd = False Then
  2831.     
  2832.     'check if saver is permitted to run
  2833.     If CheckIfValidSaver(1) = 0 Then
  2834.       Exit Sub
  2835.     End If
  2836.     
  2837.     ' set tick rate down
  2838.     Tick.Interval = 1000
  2839.  
  2840.     ' start with original screen
  2841.     picture = original.Image
  2842.     
  2843.     'find background color
  2844.     m = QBColor(0)
  2845.  
  2846.     PlotInit = True
  2847.  
  2848.     Number = Rnd * 16 + 4
  2849.     'Number = 20
  2850.  
  2851.     BoxHeight = ScaleHeight / Number
  2852.     BoxWidth = ScaleWidth / Number
  2853.  
  2854.     'initialize blocks
  2855.     ReDim x1da(Number, Number) As Integer
  2856.     ReDim y1da(Number, Number) As Integer
  2857.     For x1 = 1 To Number
  2858.     For y1 = 1 To Number
  2859.         x1da(x1, y1) = (x1 - 1) * BoxWidth
  2860.         y1da(x1, y1) = (y1 - 1) * BoxHeight
  2861.     Next y1
  2862.     Next x1
  2863.  
  2864.   Else 'reset changes done by previous init
  2865.  
  2866.     ReDim x1da(0, 0) As Integer
  2867.     ReDim y1da(0, 0) As Integer
  2868.  
  2869.     'reset tick rate
  2870.     Tick.Interval = 50
  2871.  
  2872.     ClearScreen
  2873.  
  2874.   End If
  2875.  
  2876.   Else  ' put run code here
  2877.  
  2878.     If Int(Rnd * 2) = 1 Then 'shift column
  2879.     x1 = Rnd * Number + 1: If x1 > Number Then x1 = 1
  2880.     If Int(Rnd * 2) = 1 Then 'shift down
  2881.         tempx = x1da(x1, Number)
  2882.         tempy = y1da(x1, Number)
  2883.         For y1 = Number To 2 Step -1
  2884.         x1da(x1, y1) = x1da(x1, y1 - 1)
  2885.         y1da(x1, y1) = y1da(x1, y1 - 1)
  2886.  
  2887.         'BitBlt Box to x1,y1
  2888.         DC = original.hDC
  2889.         x = (x1 - 1) * BoxWidth
  2890.         y = (y1 - 1) * BoxHeight
  2891.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2892.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2893.         Next y1
  2894.         y1 = 1
  2895.         x1da(x1, y1) = tempx
  2896.         y1da(x1, y1) = tempy
  2897.  
  2898.         'BitBlt Box to x1,y1
  2899.         DC = original.hDC
  2900.         x = (x1 - 1) * BoxWidth
  2901.         y = (y1 - 1) * BoxHeight
  2902.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2903.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2904.  
  2905.     Else ' shift up
  2906.  
  2907.         tempx = x1da(x1, 1)
  2908.         tempy = y1da(x1, 1)
  2909.         For y1 = 1 To (Number - 1)
  2910.         x1da(x1, y1) = x1da(x1, y1 + 1)
  2911.         y1da(x1, y1) = y1da(x1, y1 + 1)
  2912.  
  2913.         'BitBlt Box to x1,y1
  2914.         DC = original.hDC
  2915.         x = (x1 - 1) * BoxWidth
  2916.         y = (y1 - 1) * BoxHeight
  2917.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2918.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2919.         
  2920.         Next y1
  2921.         y1 = Number
  2922.         x1da(x1, y1) = tempx
  2923.         y1da(x1, y1) = tempy
  2924.  
  2925.         'BitBlt Box to x1,y1
  2926.         DC = original.hDC
  2927.         x = (x1 - 1) * BoxWidth
  2928.         y = (y1 - 1) * BoxHeight
  2929.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2930.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2931.  
  2932.     End If
  2933.  
  2934.     Else ' shift row
  2935.     
  2936.     y1 = Rnd * Number + 1: If y1 > Number Then y1 = 1
  2937.     If Int(Rnd * 2) = 1 Then 'shift right
  2938.         tempx = x1da(Number, y1)
  2939.         tempy = y1da(Number, y1)
  2940.         For x1 = Number To 2 Step -1
  2941.         x1da(x1, y1) = x1da(x1 - 1, y1)
  2942.         y1da(x1, y1) = y1da(x1 - 1, y1)
  2943.  
  2944.         'BitBlt Box to x1,y1
  2945.         DC = original.hDC
  2946.         x = (x1 - 1) * BoxWidth
  2947.         y = (y1 - 1) * BoxHeight
  2948.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2949.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2950.  
  2951.         Next x1
  2952.         x1 = 1
  2953.         x1da(x1, y1) = tempx
  2954.         y1da(x1, y1) = tempy
  2955.         
  2956.         'BitBlt Box to x1,y1
  2957.         DC = original.hDC
  2958.         x = (x1 - 1) * BoxWidth
  2959.         y = (y1 - 1) * BoxHeight
  2960.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2961.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2962.  
  2963.     Else 'shift left
  2964.  
  2965.         tempx = x1da(1, y1)
  2966.         tempy = y1da(1, y1)
  2967.         For x1 = 1 To (Number - 1)
  2968.         x1da(x1, y1) = x1da(x1 + 1, y1)
  2969.         y1da(x1, y1) = y1da(x1 + 1, y1)
  2970.  
  2971.         'BitBlt Box to x1,y1
  2972.         DC = original.hDC
  2973.         x = (x1 - 1) * BoxWidth
  2974.         y = (y1 - 1) * BoxHeight
  2975.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2976.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2977.  
  2978.         Next x1
  2979.         x1 = Number
  2980.         x1da(x1, y1) = tempx
  2981.         y1da(x1, y1) = tempy
  2982.         
  2983.         'BitBlt Box to x1,y1
  2984.         DC = original.hDC
  2985.         x = (x1 - 1) * BoxWidth
  2986.         y = (y1 - 1) * BoxHeight
  2987.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2988.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2989.  
  2990.     End If
  2991.  
  2992.     End If
  2993.  
  2994.   End If
  2995.  
  2996.  
  2997. End Sub
  2998.  
  2999. Sub ReadPriorities ()
  3000.     
  3001.   Dim i As Integer, j As Integer
  3002.   Dim temp As String * 30, Out  As String
  3003.   Dim Priority As Single
  3004.   ReDim PriorityBreakPoints(MaxPlotType + 1) As Single
  3005.   ReDim Priorities(MaxPlotType) As Integer
  3006.   TotalPriority = 0
  3007.  
  3008.   For i = 1 To MaxPlotType
  3009.     j = GetPrivateProfileString(secName, PriorityBaseName + Int2Str(i), "1", temp, 28, iniName)
  3010.     Priority = Val(temp)
  3011.  
  3012.     Out = Out + Str$(Priority)
  3013.  
  3014.     If Priority < 0# Then Priority = 0#
  3015.  
  3016.     If Priority = 0# Then
  3017.       Priorities(i) = 0
  3018.     Else
  3019.       Priorities(i) = 1
  3020.     End If
  3021.     
  3022.     TotalPriority = TotalPriority + Priority
  3023.     PriorityBreakPoints(i) = TotalPriority
  3024.   Next
  3025.  
  3026.   LogFile "Priorites set to " + Out, 0
  3027.  
  3028.   PriorityBreakPoints(MaxPlotType + 1) = TotalPriority + 3.402E+38
  3029.  
  3030. End Sub
  3031.  
  3032. Sub Replicate ()
  3033.  
  3034.   Dim x As Integer, y As Integer, x1 As Integer, y1 As Integer
  3035.  
  3036.   DoEvents
  3037.  
  3038.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  3039.  
  3040.   'limit sizes
  3041.   If PicWidth > ScrnWidth Then PicWidth = ScrnWidth
  3042.   If PicHeight > ScrnHeight Then PicHeight = ScrnHeight
  3043.  
  3044.   If (PicWidth < ScrnWidth) Or (PicHeight < ScrnHeight) Then
  3045.  
  3046.     'need to center picture
  3047.  
  3048.     'first backup picture
  3049.     BitBlt original.hDC, 0, 0, PicWidth, PicHeight, DC, 0, 0, &HCC0020
  3050.  
  3051.     'clear original
  3052.     'Picture = LoadPicture()
  3053.  
  3054.     ' now copy back centered
  3055.     x = ScrnWidth / 2 - PicWidth / 2
  3056.     y = ScrnHeight / 2 - PicHeight / 2
  3057.     BitBlt hDC, x, y, PicWidth, PicHeight, original.hDC, 0, 0, &HCC0020
  3058.  
  3059.  
  3060.   End If
  3061.  
  3062.   If (PicWidth < ScrnWidth) Then 'fill row
  3063.  
  3064.     '1st copy left
  3065.     x1 = x
  3066.     While x1 > 0
  3067.       BitBlt hDC, x1 - PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  3068.       x1 = x1 - PicWidth
  3069.     Wend
  3070.   
  3071.     'next copy right
  3072.     x1 = x
  3073.     While x1 < ScrnWidth
  3074.       BitBlt hDC, x1 + PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  3075.       x1 = x1 + PicWidth
  3076.     Wend
  3077.  
  3078.   End If
  3079.   
  3080.   If (PicHeight < ScrnHeight) Then
  3081.  
  3082.     '1st copy up
  3083.     y1 = y
  3084.     While y1 > 0
  3085.       BitBlt hDC, 0, y1 - PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  3086.       y1 = y1 - PicHeight
  3087.     Wend
  3088.   
  3089.     'next copy down
  3090.     y1 = y
  3091.     While y1 < ScrnHeight
  3092.       BitBlt hDC, 0, y1 + PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  3093.       y1 = y1 + PicHeight
  3094.     Wend
  3095.  
  3096.   End If
  3097.  
  3098.   i = DeleteDC(DC)
  3099.  
  3100. End Sub
  3101.  
  3102. Sub Roll ()
  3103.  
  3104.   ' the display rolls both horizontally and vertically
  3105.  
  3106.   Dim v As Integer
  3107.  
  3108.   ' if first time then initialize
  3109.   If PlotInit = False Then
  3110.     
  3111.     'see if we need to reset changes made from previous init
  3112.     If PlotEnd = False Then
  3113.     
  3114.     'check if saver is permitted to run
  3115.     If CheckIfValidSaver(1) = 0 Then
  3116.       Exit Sub
  3117.     End If
  3118.     
  3119.     ' start with original screen
  3120.     picture = original.Image
  3121.  
  3122.     PlotInit = True
  3123.  
  3124.     'Calculate velocity limits
  3125.     MaxSpeedX = ScaleWidth * 15! / 800
  3126.     MaxSpeedY = ScaleWidth * 15! / 600
  3127.  
  3128.     ' initial velocities
  3129.     vy1 = 0: vx1 = 0
  3130.  
  3131.     ' initial offset
  3132.     x1 = 0: y1 = 0
  3133.  
  3134.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  3135.  
  3136.   Else 'reset changes done by previous init
  3137.  
  3138.     ClearScreen
  3139.  
  3140.   End If
  3141.  
  3142.   Else  ' put run code here
  3143.  
  3144.     DC = original.hDC
  3145.  
  3146.     If Direction Then
  3147.     ' do vertical scroll
  3148.     BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  3149.     BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  3150.     Else
  3151.     ' do horizontal scroll
  3152.     BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  3153.     BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  3154.     End If
  3155.  
  3156.     'determine new acceleration
  3157.     ax1 = Rnd - .5
  3158.     ay1 = Rnd - .5
  3159.         
  3160.     'calculate new velocity
  3161.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3162.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3163.  
  3164.     'find new roll amount
  3165.     x1 = x1 + vx1
  3166.     If x1 > ScaleWidth Then
  3167.     x1 = x1 - ScaleWidth
  3168.     Else
  3169.     If x1 < 0 Then
  3170.         x1 = x1 + ScaleWidth
  3171.     End If
  3172.     End If
  3173.         
  3174.     y1 = y1 + vy1
  3175.     If y1 > ScaleHeight Then
  3176.     y1 = y1 - ScaleHeight
  3177.     Else
  3178.     If y1 < 0 Then
  3179.         y1 = y1 + ScaleHeight
  3180.     End If
  3181.     End If
  3182.         
  3183.   End If
  3184.  
  3185. End Sub
  3186.  
  3187. Sub RunSelection ()
  3188.  
  3189.     ' execute the appropriate selection
  3190.  
  3191.     Select Case PlotType
  3192.  
  3193.     Case 1: Squiggles
  3194.     Case 2: Kalied2
  3195.     Case 3: Polygons
  3196.     Case 4: Circles
  3197.     Case 5: Kalied
  3198.     Case 6: Lines
  3199.     Case 7: Roll
  3200.     Case 8: FilledCircles
  3201.     Case 9: Patch
  3202.     Case 10: Spiro
  3203.     Case 11: Scrape
  3204.     Case 12: Stretch
  3205.     Case 13: Dribble
  3206.     Case 14: Drop
  3207.     Case 15: Slides
  3208.     Case 16: FilledPolygons
  3209.     Case 17: MultiSpiros
  3210.     Case 18: Puzzle
  3211.     Case 19: ShootHoles
  3212.     Case 20: CyclePalette
  3213.     Case 21: Confetti
  3214.     Case Else: PlotType = 1
  3215.            RunSelection ' try again
  3216.  
  3217.     End Select
  3218.  
  3219. End Sub
  3220.  
  3221. Sub Scrape ()
  3222.  
  3223.   Static smear As Integer
  3224.  
  3225.   ' bitblt's with various patterns, dragging them
  3226.   ' across the screen randomly
  3227.  
  3228.   ' if first time then initialize
  3229.   If PlotInit = False Then
  3230.     
  3231.     'see if we need to reset changes made from previous init
  3232.     If PlotEnd = False Then
  3233.     
  3234.     'check if saver is permitted to run
  3235.     If CheckIfValidSaver(1) = 0 Then
  3236.       Exit Sub
  3237.     End If
  3238.     
  3239.     ' start with original screen
  3240.     picture = original.Image
  3241.     
  3242.     PlotInit = True
  3243.  
  3244.     'determine initial position of line
  3245.     x1 = Rnd * ScaleWidth
  3246.     y1 = Rnd * ScaleHeight
  3247.     
  3248.     'Calculate velocity limits
  3249.     MaxSpeedX = ScaleWidth * 15! / 800
  3250.     MaxSpeedY = ScaleWidth * 15! / 600
  3251.  
  3252.     BoxHeight = 400 * Rnd ^ 3 + 20
  3253.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  3254.  
  3255.     ' zero initial velocity
  3256.     vx1 = 0: vy1 = 0
  3257.  
  3258.     'default for smear
  3259.     smear = False
  3260.  
  3261.     ' choose scrape type at random
  3262.     i = Rnd * 14 + 1
  3263.     'i = 12
  3264.     Select Case i
  3265.  
  3266.     Case 1: Pattern = &H42 'Black Out
  3267.         Locked = True
  3268.     Case 2: Pattern = &HFF0062 'White Out
  3269.         Locked = True
  3270.     Case 3: Pattern = &HBB0226 'MergePaint
  3271.         Locked = False
  3272.     Case 4: Pattern = &H330008 'Not source copy
  3273.         Locked = True
  3274.     Case 5: Pattern = &H330008 'Not source copy
  3275.         Locked = False
  3276.     Case 6: Pattern = &H330008 'Not source copy
  3277.         Locked = False
  3278.         picture = LoadPicture() ' start with blank screen
  3279.     Case 7: Pattern = &H330008 'Not source copy
  3280.         smear = True
  3281.         'set random source location
  3282.         x2 = Rnd * (ScaleWidth - BoxWidth)
  3283.         y2 = Rnd * (ScaleHeight - BoxHeight)
  3284.     Case 8: Pattern = &H660046 'source invert
  3285.         Locked = True
  3286.     Case 9: Pattern = &H8800C6 'source and
  3287.         Locked = False
  3288.     Case 10: Pattern = &HEE0086 'source paint (or)
  3289.         Locked = False
  3290.     Case 11: Pattern = &H550009 'Invert Destination
  3291.         Locked = True
  3292.     Case 12: Pattern = &HCC0020 'Source Copy
  3293.         Locked = False
  3294.     Case 13: Pattern = &HCC0020 'Source Copy
  3295.         Locked = True
  3296.         picture = LoadPicture() ' start with blank screen
  3297.     Case Else: Pattern = &HCC0020 'Source Copy
  3298.         smear = True
  3299.         'set random source location
  3300.         x2 = Rnd * (ScaleWidth - BoxWidth)
  3301.         y2 = Rnd * (ScaleHeight - BoxHeight)
  3302.  
  3303.     End Select
  3304.     
  3305.   Else 'reset changes done by previous init
  3306.  
  3307.     ClearScreen
  3308.  
  3309.   End If
  3310.  
  3311.   Else  ' put run code here
  3312.  
  3313.     If smear Then
  3314.       'do nothing
  3315.     
  3316.     ' do locking if necessary
  3317.     ElseIf Locked Then
  3318.         x2 = x1: y2 = y1
  3319.     Else 'do offset
  3320.         x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  3321.         y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  3322.     End If
  3323.  
  3324.     'BitBlt Box at x1,y1
  3325.     DC = original.hDC
  3326.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  3327.     
  3328.     'determine new acceleration
  3329.     ax1 = Rnd - .5
  3330.     ay1 = Rnd - .5
  3331.         
  3332.     'calculate new position
  3333.     x1 = x1 + vx1
  3334.     y1 = y1 + vy1
  3335.         
  3336.     'calculate new velocity
  3337.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3338.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3339.         
  3340.     'check if off screen
  3341.     If (x1 > ScaleWidth - BoxWidth) Then
  3342.         'change direction
  3343.         vx1 = -Abs(vx1)
  3344.     ElseIf (x1 < 0) Then
  3345.         'change direction
  3346.         vx1 = Abs(vx1)
  3347.     End If
  3348.  
  3349.     If (y1 > ScaleHeight - BoxHeight) Then
  3350.         'change direction
  3351.         vy1 = -Abs(vy1)
  3352.     ElseIf (y1 < 0) Then
  3353.         'change direction
  3354.         vy1 = Abs(vy1)
  3355.     End If
  3356.  
  3357.     
  3358.     
  3359.   End If
  3360.  
  3361.  
  3362. End Sub
  3363.  
  3364. Sub SetWindow2DIBPalette (State As Integer)
  3365.   
  3366.   Dim i As Integer, j As Integer, k As Integer, l As Integer
  3367.   Dim usepal%
  3368.  
  3369.   'read dib palette into logical palette for cycling
  3370.   ManyLoadLogPal Pal, 0, 256, State
  3371.  
  3372.   usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  3373.    
  3374.   'this has problems:
  3375.   'i = SetPaletteEntries%(usepal%, 0, PALENTRIES, Pal.palPalEntry(0))
  3376.  
  3377.   'Pal.palNumEntries
  3378.  
  3379.   'try to set windows palette to logical palette using clipboard
  3380.   If PaletteHandle <> 0 Then
  3381.     i = DeleteObject(PaletteHandle)
  3382.   End If
  3383.   PaletteHandle = CreatePalette(Pal)
  3384.   j = OpenClipboard(hWnd)
  3385.   k = SetClipboardData(CF_PALETTE, PaletteHandle)
  3386.   l = CloseClipboard()
  3387.   picture = Clipboard.GetData(CF_PALETTE)
  3388.   Clipboard.Clear
  3389.  
  3390. End Sub
  3391.  
  3392. Sub ShootHoles ()
  3393.  
  3394.   ' shoots small holes approximately at the same place
  3395.  
  3396.   Dim i As Integer, j As Integer, k As Integer
  3397.   Dim r As Long, x As Long, y As Long
  3398.   Static Radius As Integer, HoleSize  As Integer
  3399.   Dim temp As Single
  3400.   Const pi2 = PI * 2
  3401.  
  3402.   ' if first time then initialize
  3403.   If PlotInit = False Then
  3404.     
  3405.     'see if we need to reset changes made from previous init
  3406.     If PlotEnd = False Then
  3407.     
  3408.     'check if saver is permitted to run
  3409.     If CheckIfValidSaver(1) = 0 Then
  3410.       Exit Sub
  3411.     End If
  3412.     
  3413.     ' start with original screen
  3414.     picture = original.Image
  3415.     
  3416.     PlotInit = True
  3417.  
  3418.     'determine initial position of shot
  3419.     x1 = Rnd * ScaleWidth
  3420.     y1 = Rnd * ScaleHeight
  3421.  
  3422.     'determine maximum radius of shot
  3423.     Radius = (ScaleHeight - 100) * Rnd + 100
  3424.  
  3425.     'set size of holes
  3426.     HoleSize = 20 * Rnd ^ 2 + 2
  3427.  
  3428.  
  3429.     RunMode = Int(Rnd * 3)'choose color mode to show
  3430.  
  3431.     FillStyle = 0 'solid fill
  3432.  
  3433.     If RunMode > 0 Then ' if random color then use larger spots
  3434.     i = Rnd * 255: If i > 255 Then i = 255
  3435.     j = Rnd * 255: If j > 255 Then j = 255
  3436.     k = Rnd * 255: If k > 255 Then k = 255
  3437.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  3438.     FillColor = ForeColor
  3439.     Else
  3440.  
  3441.       ForeColor = RGB(0, 0, 0)' use black box
  3442.       FillColor = RGB(0, 0, 0) 'set black fill
  3443.  
  3444.     End If
  3445.  
  3446.   Else 'reset changes done by previous init
  3447.  
  3448.     ClearScreen
  3449.     FillStyle = 1 'transparent fill
  3450.  
  3451.   End If
  3452.  
  3453. Else  ' put run code here
  3454.  
  3455.     If RunMode > 1 Then ' if random color then use larger spots
  3456.     i = Rnd * 255: If i > 255 Then i = 255
  3457.     j = Rnd * 255: If j > 255 Then j = 255
  3458.     k = Rnd * 255: If k > 255 Then k = 255
  3459.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  3460.     FillColor = ForeColor
  3461.     End If
  3462.  
  3463.     'get distance from center
  3464.     r = Rnd * Radius
  3465.  
  3466.     'get random angle
  3467.     temp = Rnd * pi2
  3468.  
  3469.     'get x portion
  3470.     x = r * Cos(temp)
  3471.  
  3472.     'get y portion
  3473.     y = r * Sin(temp)
  3474.  
  3475.     ' randomly change sign of x offset
  3476.     If Rnd > .5 Then
  3477.       x = -x
  3478.     End If
  3479.  
  3480.     ' randomly change sign of y offset
  3481.     If Rnd > .5 Then
  3482.       y = -y
  3483.     End If
  3484.  
  3485.     ' put random hole here
  3486.     Circle (x1 + x, y1 + y), HoleSize, , , , 1
  3487.  
  3488.   End If
  3489.  
  3490.  
  3491. End Sub
  3492.  
  3493. Sub ShowPal (palette As LOGPALETTE)
  3494. 'displays the current palette
  3495.  
  3496.     Dim usepal%
  3497.  
  3498.     ' Get a handle to the control's palette
  3499.     usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  3500.    
  3501.     AnimatePalette usepal%, 0, PALENTRIES, palette.palPalEntry(0)
  3502.  
  3503. End Sub
  3504.  
  3505. Sub Slides ()
  3506.  
  3507.   'cycle between different bitmaps
  3508.  
  3509.   Dim j As Integer
  3510.   Static File As String
  3511.   Static OldTime As Long
  3512.   Static running As Integer
  3513.   Dim CurTime As Long
  3514.   Dim FileName As String
  3515.  
  3516.   ' if first time then initialize
  3517.   If PlotInit = False Then
  3518.     
  3519.    'see if we need to reset changes made from previous init
  3520.    If PlotEnd = False Then
  3521.     
  3522.     'check if saver is permitted to run
  3523.     If CheckIfValidSaver(1) = 0 Then
  3524.       Exit Sub
  3525.     End If
  3526.     
  3527.     File = GetNextFile(BitmapsDir, 1, "gif", "bmp", "")
  3528.     If File = "" Then 'check if could not find bitmap
  3529.       NextSelection 'jump to next since there are no bitmap files in directory
  3530.       Exit Sub
  3531.     End If
  3532.  
  3533.     ' find file
  3534.     j = Rnd * 50 ' pick file at random
  3535.     For i = 1 To j
  3536.  
  3537.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  3538.  
  3539.     Next i
  3540.  
  3541.     i = LoadSlideAndTile(File)
  3542.     If i = 0 Then 'check if could not load
  3543.       NextSelection 'jump to next since there are no bitmap files in directory
  3544.       Exit Sub
  3545.     End If
  3546.  
  3547.     OldTime = Timer
  3548.  
  3549.     running = False
  3550.  
  3551.     PlotInit = True
  3552.  
  3553.  
  3554.   Else 'reset changes done by previous init
  3555.  
  3556.     ' save screen in place of original for latter use
  3557.     ' we do this because on palette based systems
  3558.     ' the slide procedure messes up the color
  3559.     ' palette and the Clipboard.setData 9 and
  3560.     ' Clipboard.GetData(9) sequence does not restore
  3561.     ' it, so we just use the new picture with the
  3562.     ' new palette from now on
  3563.     DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  3564.     BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  3565.     i = DeleteDC(DC)
  3566.  
  3567.     i = ManyDibFree() 'free memory used for dib
  3568.     If i <> 0 Then
  3569.       LogFile "Could not free memory", 1
  3570.     End If
  3571.  
  3572.     ClearScreen
  3573.  
  3574.   End If
  3575.  
  3576. Else  ' put run code here
  3577.  
  3578.     If running Then Exit Sub ' no recursive calls
  3579.  
  3580.     If File = "" Then Exit Sub
  3581.  
  3582.     CurTime = Timer
  3583.     If (CurTime >= OldTime) And ((OldTime + BmpSeconds) > CurTime) Then Exit Sub
  3584.  
  3585.     OldTime = Timer
  3586.  
  3587.     running = True
  3588.  
  3589.     j = Rnd * 20
  3590.  
  3591.     For i = 1 To j
  3592.  
  3593.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  3594.  
  3595.     Next i
  3596.  
  3597.     i = LoadSlideAndTile(File)
  3598.     If i = 0 Then 'check if could not load
  3599.       NextSelection 'jump to next since there are no bitmap files in directory
  3600.       Exit Sub
  3601.     End If
  3602.  
  3603.   End If
  3604.  
  3605.   running = False
  3606.  
  3607.   Exit Sub
  3608.  
  3609. End Sub
  3610.  
  3611. Sub Spiro ()
  3612.  
  3613.   'Do spirograph like figures
  3614.  
  3615.   'reserve memory
  3616.   Const Deg2Pi = PI / 180
  3617.   Static MaxRad As Integer'maximum radius for circles
  3618.   Const MaxNodes = 35'maximum number of nodes on spiro
  3619.   Dim Nodes As Integer
  3620.   Const MaxRpts = 7'max times to go around circle
  3621.   Dim Rpts As Integer
  3622.   Const PlotPoints = 1'number of points to plot each time
  3623.   Const ClearCount = 3'number on screen before clearing
  3624.   Static PlotAngleIncr As Single
  3625.   Static PlotEndAngle As Single
  3626.   Static PlotAngle As Single
  3627.   Static SinIncr As Single
  3628.   Static SinAngle As Single
  3629.   Static Xcenter As Integer
  3630.   Static Ycenter As Integer
  3631.   Static Rad1 As Integer
  3632.   Static Rad2 As Integer
  3633.   Dim r As Single
  3634.   Dim l As Integer
  3635.  
  3636.   ' if first time then initialize
  3637.   If PlotInit = False Then
  3638.     
  3639.    'see if we need to reset changes made from previous init
  3640.    If PlotEnd = False Then
  3641.     
  3642.     'check if saver is permitted to run
  3643.     If CheckIfValidSaver(0) = 0 Then
  3644.       Exit Sub
  3645.     End If
  3646.     
  3647.       PlotInit = True
  3648.       ForeColor = RGB(255, 255, 255)
  3649.       BackColor = RGB(0, 0, 0)
  3650.       Cls
  3651.  
  3652.      'initialize variables used
  3653.      PlotEndAngle = 0
  3654.      PlotAngle = 10
  3655.      MaxRad = ScaleHeight / 3'maximum radius for circles
  3656.      Pointer = 0
  3657.  
  3658.     Else 'reset changes done by previous init
  3659.  
  3660.       DrawWidth = 1' use narrow line
  3661.  
  3662.       ClearScreen
  3663.  
  3664.     End If
  3665.  
  3666.   Else  ' put run code here
  3667.  
  3668.    Do
  3669.  
  3670.     ' check if time to do new spiro
  3671.     If PlotAngle > PlotEndAngle Then
  3672.     
  3673.     'set foreground color
  3674.     ForeColor = GetBrightNonGray()
  3675.  
  3676.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  3677.     Rpts = Rnd * MaxRpts + .5
  3678.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  3679.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  3680.     Nodes = Rnd * MaxNodes + .5
  3681.     SinIncr = PlotAngleIncr * Nodes / Rpts
  3682.     SinAngle = 0
  3683.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  3684.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  3685.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  3686.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  3687.  
  3688.     DrawWidth = 1 + 2 * Rnd' use narrow line
  3689.  
  3690.     GoSub 2000 'calculate x1 and y1
  3691.  
  3692.     Pointer = Pointer + 1
  3693.     If Pointer >= ClearCount Then
  3694.       Delay 3'pause before clearing screen
  3695.       Cls
  3696.       Pointer = 0
  3697.     End If
  3698.     
  3699.     currentx = x1
  3700.     currenty = y1
  3701.  
  3702.     End If
  3703.  
  3704.     For l = 1 To PlotPoints
  3705.  
  3706.       GoSub 2000 'calculate x1 and y1
  3707.     
  3708.       'draw line
  3709.       'Line (LastX, LastY)-(x1, y1)
  3710.       Line -(x1, y1)
  3711.  
  3712.     Next l
  3713.     
  3714.     DoEvents
  3715.  
  3716.     CurrentTime = Timer
  3717.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  3718.  
  3719.    Loop
  3720.  
  3721.   End If
  3722.  
  3723.   Exit Sub
  3724.  
  3725. 2000 'calculate new point on screen
  3726.   'LastX = x1: LastY = y1
  3727.   r = Rad1 + Rad2 * Sin(SinAngle)
  3728.   x1 = r * Cos(PlotAngle) + Xcenter
  3729.   y1 = r * Sin(PlotAngle) + Ycenter
  3730.   SinAngle = SinAngle + SinIncr
  3731.   PlotAngle = PlotAngle + PlotAngleIncr
  3732.  
  3733.   Return
  3734.  
  3735. End Sub
  3736.  
  3737. Sub Squiggles ()
  3738.  
  3739.   ' draw multiple squiggles on the screen.
  3740.   ' each squiggle is assign a random color at the
  3741.   ' start, then the head travels randomly and the
  3742.   ' tail is erased
  3743.  
  3744.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  3745.   Dim il As Long, jl As Long, kl As Long
  3746.   Static SquigNumb As Integer
  3747.   Static SquigLen As Integer
  3748.   Static EndPointer As Integer, StartPointer As Integer
  3749.  
  3750.   ' if first time then initialize
  3751.   If PlotInit = False Then
  3752.     
  3753.    'see if we need to reset changes made from previous init
  3754.    If PlotEnd = False Then
  3755.     
  3756.     'check if saver is permitted to run
  3757.     If CheckIfValidSaver(0) = 0 Then
  3758.       Exit Sub
  3759.     End If
  3760.     
  3761.     PlotInit = True
  3762.     Cls
  3763.     ForeColor = QBColor(15)
  3764.  
  3765.     SquigNumb = Rnd * 10 + 10
  3766.     SquigLen = Rnd * 100 + 50
  3767.  
  3768.     'Allocate Memory
  3769.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  3770.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  3771.     ReDim x1sa(SquigNumb) As Single
  3772.     ReDim y1sa(SquigNumb) As Single
  3773.     ReDim vx1sa(SquigNumb) As Single
  3774.     ReDim vy1sa(SquigNumb) As Single
  3775.     ReDim ax1sa(SquigNumb) As Single
  3776.     ReDim ay1sa(SquigNumb) As Single
  3777.     ReDim Colors(SquigNumb) As Long
  3778.     
  3779.     Pointer = 1
  3780.  
  3781.     'Print "Clearing Array"
  3782.     For j = 1 To SquigNumb
  3783.     'determine initial position of line
  3784.     x1sa(j) = Rnd * ScaleWidth
  3785.     y1sa(j) = Rnd * ScaleHeight
  3786.  
  3787.     For i = 1 To SquigLen
  3788.         x1da(i, j) = x1sa(j)
  3789.         y1da(i, j) = y1sa(j)
  3790.     Next i
  3791.  
  3792.     Next j
  3793.     
  3794.     'find background color
  3795.     m = QBColor(0)
  3796.  
  3797.     ' get colors
  3798.     For ii = 1 To SquigNumb
  3799.     Colors(ii) = GetBrightNonGray()
  3800.     Next ii
  3801.  
  3802.     'Calculate velocity limits
  3803.     MaxSpeedX = ScaleWidth * 15! / 800
  3804.     MaxSpeedY = ScaleWidth * 15! / 600
  3805.  
  3806.   Else 'reset changes done by previous init
  3807.  
  3808.     ReDim x1da(0, 0)  As Integer
  3809.     ReDim y1da(0, 0)  As Integer
  3810.     ReDim x1sa(0) As Single
  3811.     ReDim y1sa(0) As Single
  3812.     ReDim vx1sa(0) As Single
  3813.     ReDim vy1sa(0) As Single
  3814.     ReDim ax1sa(0) As Single
  3815.     ReDim ay1sa(0) As Single
  3816.     ReDim Colors(0) As Long
  3817.  
  3818.     ClearScreen
  3819.  
  3820.   End If
  3821.  
  3822.   Else  ' put run code here
  3823.   
  3824.  
  3825.     'find where tail line went to
  3826.     If Pointer < SquigLen Then
  3827.         EndPointer = Pointer + 1
  3828.     Else
  3829.         EndPointer = 1
  3830.     End If
  3831.  
  3832.     'find where new line goes
  3833.     If Pointer > 1 Then
  3834.         StartPointer = Pointer - 1
  3835.     Else
  3836.         StartPointer = SquigLen
  3837.     End If
  3838.  
  3839.     If Rnd < .1 Then 'change a color 10% of the time
  3840.     
  3841.       ii = Int(Rnd * SquigNumb + 1)' get random squiggle to change
  3842.       If ii > SquigNumb Then ii = 1
  3843.       Colors(ii) = GetBrightNonGray()
  3844.  
  3845.     End If
  3846.  
  3847.     For j = 1 To SquigNumb
  3848.     
  3849.         'Erase tails of squigles
  3850.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  3851.  
  3852.         'Save new points
  3853.         x1da(Pointer, j) = x1sa(j)
  3854.         y1da(Pointer, j) = y1sa(j)
  3855.  
  3856.         'Draw front of Squigles
  3857.         Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  3858.  
  3859.     Next j
  3860.  
  3861.     'Move pointer to next item
  3862.     Pointer = Pointer + 1
  3863.     If Pointer > SquigLen Then
  3864.         Pointer = 1
  3865.     End If
  3866.  
  3867.     For j = 1 To SquigNumb
  3868.  
  3869.         'determine new acceleration
  3870.         ax1sa(j) = Rnd * 4 - 2
  3871.         ay1sa(j) = Rnd * 4 - 2
  3872.  
  3873.         'calculate new position
  3874.         x1sa(j) = x1sa(j) + vx1sa(j)
  3875.         y1sa(j) = y1sa(j) + vy1sa(j)
  3876.  
  3877.         'calculate new velocity
  3878.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  3879.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  3880.  
  3881.         'check if off screen
  3882.         If (x1sa(j) > ScaleWidth) Then
  3883.         x1sa(j) = ScaleWidth
  3884.         'change direction
  3885.         vx1sa(j) = -Abs(vx1sa(j))
  3886.         ElseIf (x1sa(j) < 0) Then
  3887.         x1sa(j) = 0
  3888.         'change direction
  3889.         vx1sa(j) = Abs(vx1sa(j))
  3890.         End If
  3891.  
  3892.         If (y1sa(j) > ScaleHeight) Then
  3893.         y1sa(j) = ScaleHeight
  3894.         'change direction
  3895.         vy1sa(j) = -Abs(vy1sa(j))
  3896.         ElseIf (y1sa(j) < 0) Then
  3897.         y1sa(j) = 0
  3898.         'change direction
  3899.         vy1sa(j) = Abs(vy1sa(j))
  3900.         End If
  3901.  
  3902.     Next j
  3903.     
  3904.   End If
  3905.  
  3906. End Sub
  3907.  
  3908. Sub Stretch ()
  3909.  
  3910.     Dim x As Integer, y As Integer
  3911.     Static ShadowDC As Integer
  3912.     Static oldBM As Integer
  3913.  
  3914.   ' does a StretchBlt from a random box within the Original
  3915.   ' image and then displays it on the screen
  3916.  
  3917.   ' if first time then initialize
  3918.   If PlotInit = False Then
  3919.     
  3920.     'see if we need to reset changes made from previous init
  3921.     If PlotEnd = False Then
  3922.     
  3923.     'check if saver is permitted to run
  3924.     If CheckIfValidSaver(1) = 0 Then
  3925.       Exit Sub
  3926.     End If
  3927.     
  3928.     'see how many colors display can handle
  3929.     If TotalNumColors <= 256 Then 'see if palette based
  3930.       LogFile ("Saver does not work in palette display mode: " + Str$(PlotType)), 0
  3931.       NextSelection 'jump to next since this does not work
  3932.             'well with palettes
  3933.       Exit Sub
  3934.     End If
  3935.     
  3936.     ' set tick rate down
  3937.     Tick.Interval = 300
  3938.  
  3939.     ' start with original screen
  3940.     picture = original.Image
  3941.  
  3942.     ' start temp form same as original
  3943.     DC = original.hDC
  3944.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  3945.     'BitBlt Temp.hDC, 0, 0, ScaleWidth, ScaleHeight, hDC, 0, 0, &HCC0020
  3946.  
  3947.     'create hidden DC
  3948.     'ShadowDC = CreateCompatibleDC(hDC)
  3949.     'oldBM = SelectObject(ShadowDC, Original.Image)
  3950.  
  3951.     PlotInit = True
  3952.  
  3953.     'initial position is 1:1 copy
  3954.     x1 = 0
  3955.     y1 = 0
  3956.     x2 = ScaleWidth
  3957.     y2 = ScaleHeight
  3958.     
  3959.     'Calculate velocity limits
  3960.     MaxSpeedX = ScaleWidth * 15! / 800
  3961.     MaxSpeedY = ScaleWidth * 15! / 600
  3962.  
  3963.     ' zero initial velocity
  3964.     vx1 = MaxSpeedX * Rnd
  3965.     vy1 = MaxSpeedY * Rnd
  3966.     vx2 = -MaxSpeedX * Rnd
  3967.     vy2 = -MaxSpeedY * Rnd
  3968.  
  3969.     Pattern = &HCC0020 'Source Copy
  3970.   
  3971.   Else 'reset changes done by previous init
  3972.  
  3973.     ClearScreen
  3974.  
  3975.     'reset tick rate
  3976.     Tick.Interval = 50
  3977.  
  3978.     'destroy Device context
  3979.     'i = SelectObject(ShadowDC, oldBM)
  3980.     'i = DeleteDC(ShadowDC)
  3981.  
  3982.   End If
  3983.  
  3984.   Else  ' put run code here
  3985.  
  3986.     'make sure x1,y1 less than x2,y2 or swap
  3987.     If x1 > x2 Then x = x1: x1 = x2: x2 = x
  3988.     If y1 > y2 Then y = y1: y1 = y2: y2 = y
  3989.  
  3990.     'make sure that source box size does not
  3991.     'go below a minimum
  3992.     If x2 - x1 < 40 Then x2 = x1 + 40
  3993.     If y2 - y1 < 40 Then y2 = y1 + 40
  3994.  
  3995.     'Stretch Box from x1,y1 to x2,y2 onto display
  3996.  
  3997.     ' direct route does not work right:
  3998.     'DC = Original.hDC
  3999.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  4000.  
  4001.     'indirect route does not work on pallete display modes:
  4002.     DC = original.hDC
  4003.     x = x2 - x1: y = y2 - y1
  4004.     i = StretchBlt(temp.hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  4005.     ' now that it has been stretched, write to display
  4006.     DC = temp.hDC
  4007.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  4008.  
  4009.     'try this method:
  4010.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, ShadowDC, x1, y1, x, y, &HCC0020)
  4011.     
  4012.     'determine new acceleration
  4013.     ax1 = Rnd - .5
  4014.     ay1 = Rnd - .5
  4015.     ax2 = Rnd - .5
  4016.     ay2 = Rnd - .5
  4017.         
  4018.     'calculate new position
  4019.     x1 = x1 + vx1
  4020.     y1 = y1 + vy1
  4021.     x2 = x2 + vx2
  4022.     y2 = y2 + vy2
  4023.  
  4024.     'calculate new velocity
  4025.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  4026.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  4027.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  4028.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  4029.  
  4030.     'check if off screen
  4031.     If (x1 >= ScaleWidth) Then
  4032.         'change direction
  4033.         vx1 = -Abs(vx1)
  4034.         x1 = ScaleWidth - 1
  4035.     ElseIf (x1 < 0) Then
  4036.         'change direction
  4037.         vx1 = Abs(vx1)
  4038.         x1 = 0
  4039.     End If
  4040.  
  4041.     If (y1 >= ScaleHeight) Then
  4042.         'change direction
  4043.         vy1 = -Abs(vy1)
  4044.         y1 = ScaleHeight - 1
  4045.     ElseIf (y1 < 0) Then
  4046.         'change direction
  4047.         vy1 = Abs(vy1)
  4048.         y1 = 0
  4049.     End If
  4050.  
  4051.     'check if off screen
  4052.     If (x2 >= ScaleWidth) Then
  4053.         'change direction
  4054.         vx2 = -Abs(vx2)
  4055.         x2 = ScaleWidth - 1
  4056.     ElseIf (x2 < 0) Then
  4057.         'change direction
  4058.         vx2 = Abs(vx2)
  4059.         x2 = 0
  4060.     End If
  4061.  
  4062.     If (y2 >= ScaleHeight) Then
  4063.         'change direction
  4064.         vy2 = -Abs(vy2)
  4065.         y2 = ScaleHeight - 1
  4066.     ElseIf (y2 < 0) Then
  4067.         'change direction
  4068.         vy2 = Abs(vy2)
  4069.         y2 = 0
  4070.     End If
  4071.  
  4072.     
  4073.   End If
  4074.  
  4075. End Sub
  4076.  
  4077. Sub Tick_Timer ()
  4078.  
  4079.     ' check elapsed time to see if need to change type of plot
  4080.     ' also check if past midnight
  4081.     CurrentTime = Timer
  4082.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  4083.     MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  4084.  
  4085.     ZOrder 0' make sure form is still on top
  4086.  
  4087.     'clear old saver
  4088.     PlotInit = False: PlotEnd = True
  4089.     LogFile ("Cleanup of" + Str$(PlotType)), 1
  4090.     RunSelection 'just clean up after running
  4091.     'LogFile ("After Cleanup of " + Str$(PlotType)), 1
  4092.  
  4093.     'see if we want random selection
  4094.     NextSelection 'get new PlotType
  4095.  
  4096.     PlotInit = False: PlotEnd = False
  4097.  
  4098.     'remove password prompt
  4099.     PasswordLabel.Visible = False
  4100.  
  4101.     End If
  4102.     
  4103.     LastTime = CurrentTime
  4104.  
  4105.     RunSelection
  4106.  
  4107. End Sub
  4108.  
  4109.