home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-06-16 | 3.0 KB | 134 lines |
- ' ---------------------------------
- '
- ' AMOSPro Compiler Example
- '
- ' Bumpin' Logo!
- '
- ' By Jean-Baptiste BOLCATO
- '
- ' (c) 1993 Europress Software Ltd.
- '
- ' ---------------------------------
- '
- ' ----------------------------------------------------
- ' remark: Only one Loop of this routine seems to
- ' take quite a long time !
- ' (more than 10 minutes on an unexpanded A500!)
- '
- ' So, please be patient: the result is Cool!
- '
- ' Average Acceleration: 220 %
- '
- ' Test configuration: A1200, 6Mb
- ' Original AMOS Compiler: 150 %
- ' -----------------------------------------------------
-
-
- ' ---- Variables Init ----
-
- ' Deformation radius
- R0=80
-
- ' Coord destination
- XD1=0 : YD1=0
- XD2=320 : YD2=200
-
- ' Limits of loops
- ' (try NL0=1 to NL1=10 and add a 'saveiff' to build an anim for example!)
- NL0=5 : NL1=5
-
- ' ---- Parameter screen ----
-
- Screen Open 0,320,200,2,Lowres
- Palette 0,$FFF : Curs Off : Cls 0
- Paper 0 : Pen 1 : Ink 1
- Double Buffer : Autoback 0 : Hide
- Limit Mouse 1,1 To 160,160
- Repeat
- Cls 0
- Home : Print "Choose a radius limit for deformation:"
- R0=X Mouse
- Circle 160,100,R0
- Screen Swap
- Wait Vbl
- Until Mouse Click
-
- ' ---- Screen Init ----
-
- Load Iff "AMOSPro_Extras:Compiler_Examples/graphics/demo_pic.iff",1
- Screen Hide 1
- Screen Open 0,Screen Width,Screen Height,Screen Colour,Lowres
- Flash Off : Curs Off : Cls 0
- Get Palette 1
-
- ' ---- Main Loop ----
-
- Degree
- Timer=0
-
- For N=NL0 To NL1
-
- Cls 0
-
- ' Describe all the picture: XD1,YD1 to XD2,YD2
-
- For Y=YD1 To YD2-1
- For X=XD1 To XD2-1
-
- ' Progress spot
- Plot X,Y,1
-
- ' Calculate distance between actual pixel & centre of screen
- R=Sqr((X-160)^2+(Y-100)^2)
-
- ' If outside the radius: no deformation
- If R>R0
- Screen 1 : IK=Point(X,Y)
- Screen 0 : Plot X,Y,IK
-
- ' If inside the radius: let's deform!
- Else
-
- ' Here's the math part!
- 'Bump
- H=(R0-R)*90 : H=H/R0
- H=-256*Cos(H) : Add H,256
- H=N*H : H=H/4 : Add H,256
- X2=160+((X-160)*H)/256
- Y2=100+((Y-100)*H)/256
-
- 'Another example: Rotation.
- 'A#=((R0-R#)*N)/10
- 'X2=160+(X-160)*Cos(A#)+(Y-100)*Sin(A#)
- 'Y2=100+(Y-100)*Cos(A#)-(X-160)*Sin(A#)
-
- ' If inside screen, draw the shifted pixel
- If X2>0 and X2<320 and Y2>0 and Y2<200
- Screen 1 : IK=Point(X2,Y2)
- Else
- IK=0
- End If
- Screen 0 : Plot X,Y,IK
-
- End If
-
- Next X
- Next Y
-
- Wait Vbl
-
- Next N
- T#=Timer
-
- ' --- Final Report ---
-
- Autoback 1 : Paper 0 : Pen 1
- Print " Needs";T#/50;" seconds for";NL;" loops."
- Print " ( =";T#/(NL1-NL0+1);" VBLs )"
- Print
- Print " Press mouse key to end"
-
- Repeat
- Multi Wait
- Until Mouse Key or(Inkey$<>"")
- End