home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Amos / amproe2x.dms / in.adf / Compiler_Examples / AMOS_versions / Bump.AMOS / Bump.amosSourceCode
Encoding:
AMOS Source Code  |  1993-06-16  |  3.0 KB  |  134 lines

  1. ' ---------------------------------  
  2. '
  3. ' AMOSPro Compiler Example 
  4. '
  5. ' Bumpin' Logo!
  6. '
  7. ' By Jean-Baptiste BOLCATO 
  8. '
  9. ' (c) 1993 Europress Software Ltd. 
  10. '
  11. ' ---------------------------------  
  12. '
  13. ' ----------------------------------------------------     
  14. ' remark:   Only one Loop of this routine seems to   
  15. '           take quite a long time !     
  16. '           (more than 10 minutes on an unexpanded A500!)      
  17. '
  18. '           So, please be patient: the result is Cool!     
  19. '
  20. '            Average Acceleration:  220 %  
  21. '
  22. '            Test configuration: A1200, 6Mb  
  23. '            Original AMOS Compiler:  150 %  
  24. ' -----------------------------------------------------      
  25.  
  26.  
  27. ' ---- Variables Init ---- 
  28.  
  29. ' Deformation radius 
  30. R0=80
  31.  
  32. ' Coord destination
  33. XD1=0 : YD1=0
  34. XD2=320 : YD2=200
  35.  
  36. ' Limits of loops  
  37. ' (try NL0=1 to NL1=10 and add a 'saveiff' to build an anim for example!)  
  38. NL0=5 : NL1=5
  39.  
  40. ' ---- Parameter screen ---- 
  41.  
  42. Screen Open 0,320,200,2,Lowres
  43. Palette 0,$FFF : Curs Off : Cls 0
  44. Paper 0 : Pen 1 : Ink 1
  45. Double Buffer : Autoback 0 : Hide 
  46. Limit Mouse 1,1 To 160,160
  47. Repeat 
  48.    Cls 0
  49.    Home : Print "Choose a radius limit for deformation:"
  50.    R0=X Mouse
  51.    Circle 160,100,R0
  52.    Screen Swap 
  53.    Wait Vbl 
  54. Until Mouse Click
  55.  
  56. ' ---- Screen Init ----
  57.  
  58. Load Iff "AMOSPro_Extras:Compiler_Examples/graphics/demo_pic.iff",1
  59. Screen Hide 1
  60. Screen Open 0,Screen Width,Screen Height,Screen Colour,Lowres
  61. Flash Off : Curs Off : Cls 0
  62. Get Palette 1
  63.  
  64. ' ---- Main Loop ----
  65.  
  66. Degree 
  67. Timer=0
  68.  
  69. For N=NL0 To NL1
  70.    
  71.    Cls 0
  72.    
  73.    ' Describe all the picture: XD1,YD1 to XD2,YD2 
  74.    
  75.    For Y=YD1 To YD2-1
  76.       For X=XD1 To XD2-1
  77.          
  78.          ' Progress spot
  79.          Plot X,Y,1
  80.          
  81.          ' Calculate distance between actual pixel & centre of screen   
  82.          R=Sqr((X-160)^2+(Y-100)^2)
  83.          
  84.          ' If outside the radius: no deformation
  85.          If R>R0
  86.             Screen 1 : IK=Point(X,Y)
  87.             Screen 0 : Plot X,Y,IK
  88.             
  89.             ' If inside the radius: let's deform!  
  90.          Else 
  91.             
  92.             ' Here's the math part!  
  93.             'Bump
  94.             H=(R0-R)*90 : H=H/R0
  95.             H=-256*Cos(H) : Add H,256
  96.             H=N*H : H=H/4 : Add H,256
  97.             X2=160+((X-160)*H)/256
  98.             Y2=100+((Y-100)*H)/256
  99.             
  100.             'Another example: Rotation.
  101.             'A#=((R0-R#)*N)/10 
  102.             'X2=160+(X-160)*Cos(A#)+(Y-100)*Sin(A#)
  103.             'Y2=100+(Y-100)*Cos(A#)-(X-160)*Sin(A#)
  104.             
  105.             ' If inside screen, draw the shifted pixel 
  106.             If X2>0 and X2<320 and Y2>0 and Y2<200
  107.                Screen 1 : IK=Point(X2,Y2)
  108.             Else 
  109.                IK=0
  110.             End If 
  111.             Screen 0 : Plot X,Y,IK
  112.             
  113.          End If 
  114.          
  115.       Next X
  116.    Next Y
  117.    
  118.    Wait Vbl 
  119.    
  120. Next N
  121. T#=Timer
  122.  
  123. ' --- Final Report --- 
  124.  
  125. Autoback 1 : Paper 0 : Pen 1
  126. Print "  Needs";T#/50;" seconds for";NL;" loops."
  127. Print "          ( =";T#/(NL1-NL0+1);" VBLs )"
  128. Print 
  129. Print "    Press mouse key to end"
  130.  
  131. Repeat 
  132.    Multi Wait 
  133. Until Mouse Key or(Inkey$<>"")
  134. End