home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO6.DMS / in.adf / Procedures / Graphics / _Splines.AMOS / _Splines.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-29  |  2.1 KB  |  56 lines

  1. '******************************************************* 
  2. '*                                                     * 
  3. '* AMOS Professional Procedure Library                 * 
  4. '*                                                     * 
  5. '* Procedure: Spline Drawing                           *   
  6. '*                                                     * 
  7. '*    Author: Hedwig Janssens                          *   
  8. '*                                                     * 
  9. '******************************************************* 
  10.  
  11. '------- Initialize screen,palette and coordinate stack -------
  12. Screen Open 0,320,256,32,LORES
  13. Flash Off : Curs Off : Hide 
  14. For R=0 To 31 : Colour R,256*(R/2)+16*(R/3) : Next R : Colour 31,$FD0
  15. Cls 0
  16. Dim X1(31),Y1(31),X2(31),Y2(31),X3(31),Y3(31)
  17. P=1
  18. '
  19. '------- Randomize starting positions -------------------------
  20. X1=Rnd(318) : Y1=Rnd(254) : X1D=-4 : Y1D=6
  21. X2=Rnd(318) : Y2=Rnd(254) : X2D=4 : Y2D=4
  22. X3=Rnd(318) : Y3=Rnd(254) : X3D=4 : Y3D=-6
  23. '
  24. Do 
  25. '-------- Check screen borders and bounce back ----------------  
  26.    X1=X1+X1D : If X1>318 or X1<1 Then X1D=-X1D
  27.    Y1=Y1+Y1D : If Y1>253 or Y1<1 Then Y1D=-Y1D
  28.    X2=X2+X2D : If X2>318 or X2<1 Then X2D=-X2D
  29.    Y2=Y2+Y2D : If Y2>253 or Y2<1 Then Y2D=-Y2D
  30.    X3=X3+X3D : If X3>318 or X3<1 Then X3D=-X3D
  31.    Y3=Y3+Y3D : If Y3>253 or Y3<1 Then Y3D=-Y3D
  32.    Ink 0 : _SPLINE[X1(P),Y1(P),X2(P),Y2(P),X3(P),Y3(P),8]
  33.    Shift Up 320,1,31,1
  34.    Ink P : _SPLINE[X1,Y1,X2,Y2,X3,Y3,8]
  35. '------ Put coordinates in stack for making a trail ---------- 
  36.    X1(P)=X1 : Y1(P)=Y1 : X2(P)=X2 : Y2(P)=Y2 : X3(P)=X3 : Y3(P)=Y3
  37.    Add P,1,1 To 31
  38. Loop 
  39. '
  40. Procedure _SPLINE[XB,YB,XE,YE,XC,YC,S]
  41.    '  
  42.    ' Inputs: XB,YB  Begin coordinate spline     
  43.    '         XE,YE  End coordinate spline       
  44.    '         XC,YC  Control coordinate spline   
  45.    '         S      Number of Subdivisions for building curve     
  46.    ' Outputs: Plots to current screen in current color  
  47.    '
  48.    FL=0
  49.    For ST=0 To S
  50.       XS1=XB-((XB-XC)*ST)/S : YS1=YB-((YB-YC)*ST)/S
  51.       XS2=XC-((XC-XE)*ST)/S : YS2=YC-((YC-YE)*ST)/S
  52.       XS=XS1-((XS1-XS2)*ST)/S : YS=YS1-((YS1-YS2)*ST)/S
  53.       If FL=0 Then FL=1 Else Draw XO,YO To XS,YS
  54.       XO=XS : YO=YS
  55.    Next ST
  56. End Proc