Author Topic: Sierpinski on Plasma  (Read 1387 times)

B+

  • Guest
Sierpinski on Plasma
« on: April 17, 2016, 09:12:32 pm »
An example:

Code: [Select]
' sier on plasma.bas  SmallBASIC 0.12.2 [B+=MGA] 2016-04-17
'posted version with ball and cube along with plasma

while 1
  cls
  sier 0,0,xmax,ymax
  sier 0,ymax/2-.1*ymax,.2*xmax,.2*ymax
  sier xmax-.2*xmax,ymax/2-.1*ymax,.2*xmax,.2*ymax
  delay 2000
wend

pause

sub sier(tlx,tly,width,height)
  local ax,ay,bx,by,cx,cy,px,py,top,n,a,a1,r1,r2,g1,g2,b1,b2,c1,c2
  ax = tlx
  ay = tly+height
  bx = tlx+width
  by = tly+height
  cx = tlx+width/2
  cy = tly
  px = tlx
  py = tly+height
  top=width*height*.25
  a=127:a1=63
  r1=rnd^2:g1=rnd^2:b1=rnd^2
  r2=rnd^2:g2=rnd^2:b2=rnd^2
  for n=0 to top
    c1=RGB(a+a*sin(r1*px),a+a*sin(g1*px),a+a*sin(b1*px))
    c2=RGB(a1+a1*sin(r2*px),a1+a1*sin(g2*px),a1+a1*sin(b2*px))
    pset px,py,c1   
    pset px,ymax/2-(py-ymax/2),c2  '<=== BOGO, buy one get one half off
    select Case int(rnd*3)
    case 0
      px = (px + ax) / 2.0
      py = (py + ay) / 2.0
    case 1
      px = (px + bx) / 2.0
      py = (py + by) / 2.0
    case 2
      px = (px + cx) / 2.0
      py = (py + cy) / 2.0
    end select       
  next
  showpage
end
« Last Edit: April 18, 2016, 01:44:51 am by B+ »

B+

  • Guest
Blabalonian Morph
« Reply #1 on: April 21, 2016, 04:10:03 pm »
Code: [Select]
' sier on plasma 3.bas  SmallBASIC 0.12.2 [B+=MGA] 2016-04-21

'Blabalonian Morph

while 1
  cls
  sier 0,0,xmax,ymax
  pause
wend

sub sier(tlx,tly,width,height)
  local a,a1,ax,ay,bx,by,cx,cy,px,py,top,n,r1,r2,g1,g2,b1,b2,c1,c2
  ax = tlx
  ay = tly+height
  bx = tlx+width
  by = tly+height
  cx = tlx+width/2
  cy = tly
  px = tlx
  py = tly+height
  top=width*height*.5
  if c=0 then c=(rnd*14)\1+1
  a=127:a1=63
  r1=rnd^2:g1=rnd^2:b1=rnd^2
  r2=rnd^2:g2=rnd^2:b2=rnd^2
  for n=0 to top
    c1=RGB(a+a*sin(r1*px),a+a*sin(g1*px),a+a*sin(b1*px))
    c2=RGB(a1+a1*cos(r2*py),a1+a1*cos(g2*py),a1+a1*cos(b2*py))
    pset px,py,c2   
    pset px,ymax/2-(py-ymax/2),c1
    select Case int(rnd*3)
    case 0
      px = (px + ax) / 2.0
      py = (py + ay) / 2.0
    case 1
      px = (px + bx) / 2.0
      py = (py + by) / 2.0
    case 2
      px = (px + cx) / 2.0
      py = (py + cy) / 2.0
    end select       
  next
end