Posted: 29th Jan 2004 11:12
I'm bored again...

+ Code Snippet
Rem Project: beziers screensaver
Rem Created: 1/29/2004 3:56:07 AM

Rem ***** Main Source File *****
set display mode 800,600,32
randomize timer()
sync on
sync rate 60
hide mouse

rem screen width
width = screen width()
rem screen height
height = screen height()
rem movement speed
speed as integer = 5
rem how many lines
line_total = 8

total = line_total * 4

dim dx#(total)
dim dy#(total)
dim a#(total)

cr as integer = 255
cg as integer = 255
cb as integer = 255

tr as integer = 0
tg as integer = 0
tb as integer = 255

color as dword
color = rgb(205,255,255)

newColorDelayAmount as integer = 3000
newColorDelay as integer

for t = 1 to total
  dx#(t) = rnd(width)
  dy#(t) = rnd(height)
  a#(t) = rnd(360)
next t


do
  cls

  for t=1 to total
    if dx#(t)>width or dx#(t)<0 or dy#(t)>height or dy#(t)<0
      dx#(t) = newxvalue(dx#(t),a#(t),speed*-1)
      dy#(t) = newzvalue(dy#(t),a#(t),speed*-1)
      a#(t) = rnd(360)
    endif
    dx#(t) = newxvalue(dx#(t),a#(t),speed)
    dy#(t) = newzvalue(dy#(t),a#(t),speed)
  next t

  if newColorDelay + newColorDelayAmount < timer()
    tr = rnd(255)
    tg = rnd(255)
    tb = rnd(255)
    newColorDelay = timer()
  endif

  color = getFadedValue(cr,cg,cb,tr,tg,tb)
  ink color,0
  cr = rgbr(color)
  cg = rgbg(color)
  cb = rgbb(color)

   for t = 1 to total step 4
      circle dx#(t), dy#(t), 5
      circle dx#(t+1), dy#(t+1), 5
   next t

   for p=1 to total step 4
      bezier(dx#(p), dy#(p), dx#(p+1), dy#(p+1), dx#(p+2), dy#(p+2), dx#(p+3), dy#(p+3))
   next p


 ` text 5,5,str$(screen fps())

  sync
loop



rem This function was downloaded from The Game Creators
rem http://www.thegamecreators.com
function Bezier(x1, y1, x2, y2, c1x, c1y, c2x, c2y)

   x as float
   y as float

   cx as float
   bx as float
   ax as float

   cy as float
   by as float
   ay as float

   x = x1
   y = y1

   cx = 3 * (c1x - x1)
   bx = 3 * (c2x - c1x) - cx
   ax = x2 - x1 - cx - bx

   cy = 3 * (c1y - y1)
   by = 3 * (c2y - c1y) - cy
   ay = y2 - y1 - cy - by

   `text x1,y1,"a"
   `text x2,y2,"b"
   `text c1x,c1y,"c1"
   `text c2x,c2y,"c2"

   for t# = 0 to 1.05 step .05

      x = ((ax * t# + bx) * t# + cx) * t# + x1
      y = ((ay * t# + by) * t# + cy) * t# + y1

      `  First time through?
      if t# = 0
         oldx = x
         oldy = y
      endif

      line oldx, oldy, x, y

      oldx = x
      oldy = y

   next t#

endfunction


rem fade current color to the targeted color
function getFadedValue(currentR,currentG,currentB,targetR, targetG, targetB) as dword

  if currentR > targetR then dec currentR,1
  if currentR < targetR then inc currentR,1

  if currentG > targetG then dec currentG,1
  if currentG < targetG then inc currentG,1

  if currentB > targetB then dec currentB,1
  if currentB < targetB then inc currentB,1

  color = rgb(currentR, currentB, currentB)

endfunction color
Posted: 29th Jan 2004 21:40
Good stuff .