rem Bezier Curves ....... Rev 2.1 rem A J Tooth // November 11th 2003 rem Improved February 2006 *FLOAT64 rem Call Utility Procedures proc_fullscreen : rem Set up use of Full Screen rem Parameter Initialisation for "Source" Curve proc_setpars *REFRESH OFF repeat cnt&=0 repeat rem Parameters for "Destination" Curve proc_setdespars rem Pick a colour, any colour r&=rnd(255) : g&=rnd(255) : b&=rnd(255) c=0.0 : rem Re-initialise Control Variable repeat sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &100 for k=0.0 to K step 0.002 rem Set Parameters for Intermediate Curves proc_setinterpars(c+k) rem Adjust Colour for Brightness f=k/K vdu 19,10,16,int(f*r&),int(f*g&),int(f*b&) gcol 10 rem Draw a single BEZIER Curve for a&=0 to num& a=a&/num& : b=1-a rem BEZIER Formulae B=b*b*b : A=a*a*a : AB=a*b x%=int(lps11*B + 3*AB*(lps21*b + lps31*a) + lps41*A) y%=int(lps12*B + 3*AB*(lps22*b + lps32*a) + lps42*A) if a&=0 then move x%,y% else draw x%,y% next a& *REFRESH next k sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &20 c+=0.04 : rem Increase Control Variable f$=inkey$(1) : rem Wait 1ms for a key to be pressed until c>1.0 or f$=" " rem Swap "Destination" Parameters for "Source" Parameters proc_swappars cnt&+=1 until f$=" " or cnt&>Lim& rem Clear the screen unless the space-bar was pressed if f$<>" " then cls until f$=" " *REFRESH ON a$=get$ quit end rem End of Program rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rem ================================================================ rem Set up use of Full Screen def proc_fullscreen sys "GetSystemMetrics", 0 to xscreen% sys "GetSystemMetrics", 1 to yscreen% sys "SetWindowLong",@hwnd%,-16,&16000000 sys "SetWindowPos",@hwnd%,-1,0,0,xscreen%,yscreen%,0 vdu 23,22,xscreen%;yscreen%;8,16,16,1 : rem Set fullscreen mode mouse off : off : rem Turns off the Mouse Pointer and the Cursor endproc rem ================================================================ rem Parameter Initialisation for "Source" Curve def proc_setpars dim lps%(8,2),phi(4),vps(2,2) @vdu%!248=3 num&=100 lps%(1,1)=rnd(2*xscreen%) : lps%(1,2)=rnd(2*yscreen%) lps%(4,1)=rnd(2*xscreen%) : lps%(4,2)=rnd(2*yscreen%) phi(1)=2*pi*rnd(1) : phi(2)=2*pi*rnd(1) st1%=300+rnd(500) : st2%=300+rnd(500) Lim&=5*rnd(5) : K=0.02 endproc rem ================================================================ rem Parameters for "Destination" Curve def proc_setdespars lps%(5,1)=rnd(2*xscreen%) : lps%(5,2)=rnd(2*yscreen%) lps%(8,1)=rnd(2*xscreen%) : lps%(8,2)=rnd(2*yscreen%) phi(3)=2*pi*rnd(1) : phi(4)=2*pi*rnd(1) st3%=300+rnd(500) : st4%=300+rnd(500) endproc rem ================================================================ rem Set Parameters for Intermediate Curves def proc_setinterpars(C) : local D,phi1,phi2 D=1-C stx=D*st1%+C*st3% : sty=D*st2%+C*st4% phi1=D*phi(1)+C*phi(3) : phi2=D*phi(2)+C*phi(4) vps(1,1)=stx*cos(phi1) : vps(1,2)=stx*sin(phi1) vps(2,1)=sty*cos(phi2) : vps(2,2)=sty*sin(phi2) lps11=D*lps%(1,1)+C*lps%(5,1) lps12=D*lps%(1,2)+C*lps%(5,2) lps21=D*lps%(1,1)+C*lps%(5,1) + vps(1,1) lps22=D*lps%(1,2)+C*lps%(5,2) + vps(1,2) lps31=D*lps%(4,1)+C*lps%(8,1) + vps(2,1) lps32=D*lps%(4,2)+C*lps%(8,2) + vps(2,2) lps41=D*lps%(4,1)+C*lps%(8,1) lps42=D*lps%(4,2)+C*lps%(8,2) endproc rem ================================================================ rem Swap "Destination" Parameters for "Source" Parameters def proc_swappars lps%(1,1)=lps%(5,1) : lps%(1,2)=lps%(5,2) lps%(4,1)=lps%(8,1) : lps%(4,2)=lps%(8,2) phi(1)=phi(3) : phi(2)=phi(4) st1%=st3% : st2%=st4% endproc rem ================================================================