08-31-2024, 01:25 AM
Code: (Select All)
$Checking:Off
Screen _NewImage(1000, 700, 32)
_ScreenMove 150, 0
Randomize Timer
Print "Overlapping lines check of FC3"
FC3 500, 350, 300, _RGB32(0, 0, 255, 100) ' check for overlapping lines
Print "Looking good! no lighter lines." ' FC passes too BTW
Print: Print " zzz... press any for timed test"
Sleep
Cls
For i = 1 To 11
If i = 1 Then ' in case going first has disadvantage don't time fisrt round
t## = Timer(.001) ' get the first call to timer over with
FC3 Rnd * (_Width - 700) + 350, 350, 350, _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
fc3_2 Rnd * (_Width - 700) + 350, 350, 350, _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
Else
'time the FC3 sub
_Delay .1
t## = Timer(.001)
For c = 1 To 2000
FC3 Rnd * (_Width - 700) + 350, 350, 350, _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
_Display
Next
t1## = t1## + Timer(.001) - t##
'time the fc2 sub
_Delay .1
t## = Timer(.001)
For c = 1 To 2000
fc3_2 Rnd * (_Width - 700) + 350, 350, 350, _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
_Display
Next
t2## = t2## + Timer(.001) - t##
End If
Next
Print
Print " FC3 ="; t1##
Print "FC3-2 ="; t2##
Print
If t2## < t1## Then
Print "fc3_2 wins!"
ElseIf t1## < t2## Then ' EDIT fixed!
Print "FC3 wins!"
Else
Print "Tie fc3_2 = FC3 tme"
End If
_Display
Sub FC3 (cx, cy, r, clr~&)
Line (cx - r, cy)-(cx + r, cy), clr~&, BF
y = 1
r2 = r * r
While y <= r
x = Sqr(r2 - y * y)
Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
Line (cx - x, cy - y)-(cx + x, cy - y), clr~&, BF
y = y + 1
Wend
End Sub
Sub fc3_2 (cx, cy, r, clr~&)
Line (cx - r, cy)-(cx + r, cy), clr~&, BF
r2 = r * r
Do Until y = r
y = y + 1
x = Sqr(r2 - y * y)
Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
Line (cx - x, cy - y)-(cx + x, cy - y), clr~&, BF
Loop
End Sub
So this is why I don't speed check on my system.
Notice both subs are the SAME, so they should run about the same time, nope. 3 runs...
Pete
Shoot first and shoot people who ask questions, later.