RetroBASIC
Basicprogramming(.org) => Code and examples => Topic started by: B+ on February 13, 2016, 09:54:26 PM
-
without recursion, random, modulus, division or even a while loop!
'Sier Carpet v3.bas SmallBASIC 0.12.2 [B+=MGA] 2016-02-13
sq=512
s=2
stepper=2*s
start=1
lc=0
label doloop
for x=start to sq step stepper
for y=start to sq step stepper
rect x,y,x+s,y+s,rgb(0,lc*15+128,0) filled
next
next
start=start+s
s=2*s
stepper=2*stepper
lc=lc+1
if stepper<=sq then goto doloop
pause 'for snapshot
-
Here is more carpet like symmetry:
'Symmetric Sier Carpet v3.bas SmallBASIC 0.12.2 [B+=MGA] 2016-02-13
sq=512
s=2
stepper=2*s
start=1
lc=0
label doloop
for x=start to sq step stepper
for y=start to sq step stepper
c=rgb(lc*15+128,0,0)
rect x,y,x+s,y+s,c filled
d=512-x
dy=512-y
rect 1024-d-s,y step s,s,c filled
rect x,1024-dy-s step s,s,c filled
rect 1024-d-s,1024-dy-s step s,s,c filled
next
next
start=start+s
s=2*s
stepper=2*stepper
lc=lc+1
if stepper<=sq then goto doloop
pause 'for snapshot
-
Hi Mark,
It looks like step can be used to increment a variable as well as the traditional FOR keyword in SmallBASIC.
-
Hi John,
Imaginative idea, but STEP is used in SmallBASIC for LINE or RECT as relative position to first x,y pair given as opposed to absolute screen coordinates.
absolute: RECT x1,y1,x2,y2
or relative: RECT x1,y1 STEP width, height
-
Has a BBC plot smell to it. :)
-
Also might sense old QB as well.