UnderwareDesign
May 18, 2013, 10:38:24 AM *
News: Creeping Angels Work In Progress by bmorris (14th,Dec,2012)
   Home    
Pages: [1]
 
Author Topic: Vortex  (Read 556 times)
Member
Development Team


WWW
« on: September 21, 2009, 12:59:31 PM »


 Vortex

  Spinning vortex thing Smiley


  
PlayBASIC Code:
 Type tPOsition
      x#
      y#
      Size
 EndType


 Size=500
 Dim Vortex(Size) as tPOsition


 TotalDegrees#=360*10
 RadiusMax=500
 RadiusMin=10
 
 For lp=0 to Size
      Angle#=(TotalDegrees#/Size)*lp
      Angle#=(TotalDegrees#/Size)*lp
      Radius#=RadiusMin+(((RadiusMax-RadiusMin)/TotalDegrees#)*Angle#)
      InitLink(lp,Angle#,Radius#)
 next



 FramesPerTransistion=20

; Setfps  75


 TicksPerTransistion = 250
 
 StartTime         =Timer()
 FrameStartTime   =Timer()
 FrameEndTime      =FrameStartTime+TicksPerTransistion

; Setfps 10
 Do
       Cls 0

      CurrentTime=Timer()

      passes=0
      While CurrentTime=>FrameEndTime

         FrameStartTime      =FrameStartTime+TicksPerTransistion
         FrameEndTime      =FrameStartTime+TicksPerTransistion
         CopyArrayCells  Vortex(),Size-1,-1,Vortex(),Size,-1,(Size)
          InitLink(0,0,RadiusMin)
         inc passes
      EndWHile

      Scaler#=Float(CurrentTime-FrameStartTime)/TicksPerTransistion
      DrawVortex(Scaler#)

    Sync
 loop





Function InitLink(INdex,Angle#,Radius#)

      sw=getScreenWidth()/2
      sh=getScreenHeight()/2

       Vortex(Index).x#=sw+Cos(Angle#)*Radius#
       Vortex(Index).y#=sh+Sin(Angle#)*Radius#
       Vortex(Index).size=rndrange(10,20)

EndFunction 
 
Function DrawVortex(Scaler#)
 
    Size=GetArrayElements(Vortex().Tposition,1)

   x1#=Vortex(0).x#
   y1#=Vortex(0).y#

      Radius=10
   
   lockbuffer
    for lp=1 to Size
         
      x2#=Vortex(lp).x#
      y2#=Vortex(lp).y#

      dx#=x2#-x1#
      dy#=y2#-y1#

      x#=x1#+(dx#*Scaler#)
      y#=y1#+(dy#*Scaler#)
      
      circle x#,y#,radius,true   

;      line x1#,y1#,x2#,y2#
    
       x1#=x2#
       y1#=y2#
    
    next
 
   unlockbuffer
 

EndFunction







   This is the screen shot version..

PlayBASIC Code:
 Type tPOsition
      x#
      y#
      Size
 EndType


 Size=1000
 Dim Vortex(Size) as tPOsition


 TotalDegrees#=360*10
 RadiusMax=500
 RadiusMin=10
 
 For lp=0 to Size
      Angle#=(TotalDegrees#/Size)*lp
      Angle#=(TotalDegrees#/Size)*lp
      Radius#=RadiusMin+(((RadiusMax-RadiusMin)/TotalDegrees#)*Angle#)
      InitLink(lp,Angle#,Radius#)
 next




 TicksPerTransistion = 250
 
 StartTime         =Timer()
 FrameStartTime   =Timer()
 FrameEndTime      =FrameStartTime+TicksPerTransistion

sw=getScreenwidth()
sh=GetSCreenHeight()
 Screen=NewFxImage(sw,sh)

 
 Do
      rendertoimage Screen



       c1=rgb(200,200,200)
      c2=rgbfade(c1,50)
      inkmode 1
       shadebox 0,0,sw,sh,c1,c2,c1,c2

      CurrentTime=Timer()
      While CurrentTime=>FrameEndTime
         FrameStartTime      =FrameStartTime+TicksPerTransistion
         FrameEndTime      =FrameStartTime+TicksPerTransistion
         CopyArrayCells  Vortex(),Size-1,-1,Vortex(),Size,-1,(Size)
          InitLink(0,0,RadiusMin)
      EndWHile

      Scaler#=Float(CurrentTime-FrameStartTime)/TicksPerTransistion

      ink Rgb(100,100,210)
      
      inkmode 1+32   ;2048
      DrawVortex(Scaler#)
      rendertoscreen
      
      drawimage Screen,0,0,0
    Sync
 loop





Function InitLink(INdex,Angle#,Radius#)

      sw=getScreenWidth()/2
      sh=getScreenHeight()/2

       Vortex(Index).x#=sw+Cos(Angle#)*Radius#
       Vortex(Index).y#=sh+Sin(Angle#)*Radius#
      
      dist#=getdistance2d(sw,sh,Vortex(Index).x#,Vortex(Index).y#)
      
       Vortex(Index).size=5+(Radius#/22)

EndFunction 
 
Function DrawVortex(Scaler#)
 
    Size=GetArrayElements(Vortex().Tposition,1)

   x1#=Vortex(0).x#
   y1#=Vortex(0).y#
   r1#=Vortex(0).Size
   
   lockbuffer
    for lp=1 to Size
         
      x2#=Vortex(lp).x#
      y2#=Vortex(lp).y#
      r2#=Vortex(lp).Size
      

      dx#=x2#-x1#
      dy#=y2#-y1#

      x#=x1#+(dx#*Scaler#)
      y#=y1#+(dy#*Scaler#)

      Radius=r1#+((r2#-r1#)*Scaler#)
      
      circle x#,y#,radius,true   

    
       x1#=x2#
       y1#=y2#
       r1#=r2#
    
    next
 
   unlockbuffer
 

EndFunction






Vortex_Pic1.jpg (60.68 KB, 808x634 - viewed 127 times.)
Logged

Member

WWW
« Reply #1 on: September 21, 2009, 02:09:32 PM »

very nice!!!^_^
Logged
Pages: [1]
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2009, Simple Machines LLC | Privacy Policy Valid XHTML 1.0! Valid CSS!