Ooops
September 29, 2020, 01:38:43 AM

Author Topic: Anyone hungry?  (Read 723 times)

Offline bplus

  • Full Member
  • ***
  • Posts: 139
Anyone hungry?
« on: November 02, 2019, 04:03:08 PM »
Here is a SmallBASIC sample:
Code: [Select]
' 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 

Offline bplus

  • Full Member
  • ***
  • Posts: 139
Re: Anyone hungry?
« Reply #1 on: November 04, 2019, 05:14:36 PM »
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! ;)

Offline lettersquash

  • Jr. Member
  • **
  • Posts: 73
    • Lettersquash Blog
Re: Anyone hungry?
« Reply #2 on: April 07, 2020, 09:22:07 PM »
Sweet. Candy sprinkes make all the difference.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal