rem Bezier Gen ........ Rev 2.1 rem A J Tooth // January 2007 on error if (err=17) then quit rem Setup proc_setup *REFRESH OFF cnt&=0 repeat rem Set new end-colours proc_colend rem Plot points proc_ptsplot rem Reassign end-points proc_reass rem Reset cnt&+=1 if cnt&=10 then Lev&=2+rnd(8) : cnt&=0 : vdm&=2+rnd(8) : cls proc_mkcheck(a$,b&) until a$<>"" or b&<>0 *REFRESH ON a$=get$ quit rem End of Program ============================================ rem =========================================================== rem Setup def proc_setup *FLOAT 64 rem Go to full screen proc_fullscreen(xscreen%,yscreen%) max%=100 : rem Max number of points Lev&=2 : rem Bezier curve level dim pts%(10,5), cols&(1,2), c&(2), xy%(max%,1) rem Set initial end-points proc_ranpts vdm&=2 endproc rem =========================================================== rem Check for a mouse or keyboard event def proc_mkcheck(return a$,return b&) local x%,y% rem Event a$=inkey$(1) mouse x%,y%,b& endproc rem =============================================================== rem Set points def proc_ranpts local a& for a&=0 to 10 pts%(a&,0)=rnd(2*xscreen%)-1 pts%(a&,1)=rnd(2*yscreen%)-1 pts%(a&,2)=rnd(2*xscreen%)-1 pts%(a&,3)=rnd(2*yscreen%)-1 next a& endproc rem =============================================================== rem Reassign end-points def proc_reass local a& for a&=0 to 10 pts%(a&,0)=pts%(a&,2) pts%(a&,1)=pts%(a&,3) pts%(a&,2)=rnd(2*xscreen%)-1 pts%(a&,3)=rnd(2*yscreen%)-1 next a& endproc rem =============================================================== rem Plot points def proc_ptsplot local p&,q&,p,q,d& cls for p&=0 to 30 p=p&/30 : q=1-p for d&=0 to Lev& pts%(d&,4)=int(q*pts%(d&,0) + p*pts%(d&,2)) pts%(d&,5)=int(q*pts%(d&,1) + p*pts%(d&,3)) next d& rem Draw the next curve proc_BezCurv *REFRESH next p& endproc rem =============================================================== rem Draw the next curve def proc_BezCurv local w&,t%,s,t,a&,xx,yy sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &100 ind&=1 for w&=vdm& to 1 step -1 @vdu%!248=int(vdm&*w&/vdm&) for t%=0 to max% t=t%/max% : s=(1-t) : rem Key parameters ranging 0 to 1 if ind&=1 then rem Calculate plot points once only xx=0.0 : yy=0.0 for a&=0 to Lev& xx+=fn_nxpt(a&,Lev&,0,s,t) yy+=fn_nxpt(a&,Lev&,1,s,t) next a& xy%(t%,0)=int(xx) xy%(t%,1)=int(yy) endif rem Change colour for each line segment for a&=0 to 2 c&(a&)=int((s*cols&(0,a&) + t*cols&(1,a&))*(2*vdm&-w&)/(2*vdm&)) next a& colour 10,c&(0),c&(1),c&(2) : gcol 10 if t%=0 then move xy%(0,0),xy%(0,1) else draw xy%(t%,0),xy%(t%,1) next t% ind&=0 next w& sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &20 endproc rem =============================================================== rem Set new end-colours def proc_colend local a&,b& for b&=0 to 1 for a&=0 to 2 cols&(b&,a&)=rnd(256)-1 next a& next b& endproc rem =============================================================== rem Combination n&-C-r& def fn_combi(r&,n&) local a&,Ans Ans=1.0 if r&>0 then for a&=1 to r& Ans*=(n&-a&+1)/(r&-a&+1) next a& endif =int(Ans) rem =============================================================== rem Combination def fn_nxpt(A&,N&,I&,S,T) local com%,fac,Ans rem Get N&-C-A& com%=fn_combi(A&,N&) rem Combination of s and t fac=(T^A&)*(S^(N&-A&)) rem Combined answer Ans=com%*fac*pts%(A&,4+I&) =Ans rem =============================================================== rem Fullscreen def proc_fullscreen(return xscreen%,return yscreen%) 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 =============================================================