Hi Galileo!
I have for a special treat for today! Update to SB code after cross pollinating with other dialects.
' In a doNUT SHELL.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-04
' translating to JB, I discovered an improvement!
' now with candy sprinkles!
const cx = xmax/2
const cy = ymax/2
const tw = txtw("W")
const th = txth("Q")
def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lo
def rclr = rgb(rand(64, 255), rand(64, 255), rand(64, 255))
sub midInk(r1, g1, b1, r2, g2, b2, fr, tf)
if tf then
fc = rClr()
else
fc = rgb(r1+(r2-r1)*(1-fr), g1+(g2-g1)*(1-fr), b1+(b2-b1)*(1-fr))
fi
bc = rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)
color fc, bc
end
open "In a doNUT SHELL.bas" for input as #1
while eof(1) = 0
input #1, fline
f = f + fline + ":"
wend
close #1
lenF = len(f)
tArea = tw * th * lenF / 2
r = sqr(9/4 * tArea/pi)
for y = 0 to ymax
for x = 0 to xmax
d = ((x - cx) ^ 2 + (y - cy) ^ 2) ^.5
if r/3 < d +20 and d - 20< r then
midink(180, 90, 55, 80, 40, 20, 1 - abs(2/3*r - d)/(.335*r), 0)
pset x+5, y+10
fi
next
next
idx = 0
for y = 0 to ymax step th
for x = 0 to xmax step tw
d = ((x - cx) ^ 2 + (y - cy) ^ 2) ^.5
if r/3 < d and d < r then
idx +=1
at x, y
midink(180, 90, 55, 80, 40, 20, abs(2/3*r - d)/(.335*r), 1)
if idx < lenF then
? mid(f, idx, 1);
else
this = iff(idx mod 2, "X", "O") : ? this;
fi
fi
next
next
print
pause