02-17-2023, 10:18 AM
@Bplus
if you remember this, here its recursive way
if you remember this, here its recursive way
Code: (Select All)
Option _Explicit
Const White = _RGB32(255), Black = _RGB32(0), Gray = _RGB32(100), Wscreen = 400, Hscreen = 400
Dim As Single Wsquare, Hsquare, Repeat, Left, Sum
Screen _NewImage(Wscreen, Hscreen, 32)
_Title "Shrinked chess pattern recursive way"
Cls , Gray
Wsquare = Wscreen / 2
Hsquare = Hscreen / 2
Repeat = 1
Sum = 0
Left = 0
pattern Wsquare, Hsquare, Repeat, Sum, Left
End
Sub pattern (Wsquare, Hsquare, Repeat, Sum, Left)
If Sum >= Wscreen Then Exit Sub
Dim a As Integer
Dim Top
_Delay .2
For a = 1 To Repeat
Line (Left, Top + (Hsquare * (a - 1)))-(Left + Wsquare, Top + (Hsquare * a)), White, BF
Line (Left, Top + (Hsquare * a))-(Left + Wsquare, Top + (Hsquare * (a + 1))), Black, BF
Top = Top + Hsquare
Next a
Repeat = Repeat * 2
Left = Left + Wsquare
Wsquare = Wsquare / 2
Hsquare = Hsquare / 2
Sum = Sum + Wsquare
Call pattern(Wsquare, Hsquare, Repeat, Sum, Left)
End Sub