Anyone hungry?

Started by bplus, November 02, 2019, 16:03:08

Previous topic - Next topic

bplus

Here is a SmallBASIC sample:

' In a doNUT SHELL.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-04
' 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, "1", "O") : ? this;
      fi
    fi
  next
next
print
pause 
1 person likes this

bplus

Dang, the mods approved the post but forgot the attached screenshot! The hole point!

OK reposted, wait... reposted is not a word the spellchecker knows, oh know! ;)
1 person likes this

lettersquash

Sweet. Candy sprinkes make all the difference.
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.