Author Topic: Tree Swirl  (Read 117 times)

B+

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
Tree Swirl
« on: 28. May 2017, 05:26:11 »
hmm... trees instead of stars?

Code: [Select]
' tree swirl.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-27
' mod with trees
' Psychedelic Star Swirl.bas  SmallBASIC 0.12.8 [B+=MGA] 2017-03-03

cx = xmax / 2 : cy = ymax / 2 : StartAngle = 0
clr = 1 : r = rnd : g = rnd : b = rnd

while 1
  cls
  Bang
  showpage
  delay 1
  StartAngle = StartAngle - pi/72
wend
 
sub Bang()
  angle = StartAngle
  size = 3 : radius = .1 : ds = .1
  while radius < 400
    x = cos(angle) * radius
    y = sin(angle) * radius
    chColor
    branch cx + x, cy + y, deg(atan2((y-cy),(x-cx))-90), size, 1
    angle = angle + 41.0
    radius = radius + 2.0
    size = size + ds
    ds = ds + 0.0001
  wend
end

sub chColor()
  clr = clr + 1
  color rgb(30+20*sin(r*clr), 167+80*sin(g*clr), 30+20*sin(r*clr))
  if clr > 10000 then r = rnd : g = rnd : b = rnd : clr = 0
end

sub branch(x, y, angD, length, lev)
  local x2, y2, dx, dy, bc, i
  x2 = x + cos(rad(angD)) * length
  y2 = y - sin(rad(angD)) * length
  line x, y, x2, y2
  if lev>6 or length<1 then exit sub
  lev+=1
  branch x2,y2,angD+10+30*rnd,.8*length+.2*rnd*length,lev
  branch x2,y2,angD-10-30*rnd,.8*length+.2*rnd*length,lev
end

:)


jj2007

  • Full Member
  • ***
  • Posts: 120
  • MasmBasic rocks
    • View Profile
    • MasmBasic - faster than C
Re: Tree Swirl
« Reply #1 on: 28. May 2017, 18:02:09 »
Beautiful!

B+

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
Re: Tree Swirl
« Reply #2 on: 28. May 2017, 18:36:43 »

Galileo

  • Newcomer
  • *
  • Posts: 48
    • View Profile
Re: Tree Swirl
« Reply #3 on: 31. May 2017, 19:21:02 »
Very good.