/* To implement Bezier Curve */ #include #include #include int a[20],b[20],m,n=0,j,d; float bx[5000],by[5000],u; union REGS i,o; initmouse() { i.x.ax=0; int86(0x33,&i,&o); return(o.x.ax); } void showmouseptr() { i.x.ax=1; int86(0x33,&i,&o); } void restrictmouseptr(int x1,int y1,int x2,int y2) { i.x.ax=7; i.x.cx=x1; i.x.dx=x2; int86(0x33,&i,&o); i.x.ax=8; i.x.cx=y1; i.x.dx=y2; int86(0x33,&i,&o); } void getmousepos(int *button,int *x,int *y) { i.x.ax=3; int86(0x33,&i,&o); *button=o.x.bx; *x=o.x.cx; *y=o.x.dx; } void hidemouseptr() { i.x.ax=2; int86(0x33,&i,&o); } int compco() { int k,coeff=1; for(k=d+1;k<=n;k++) coeff=coeff*k; for(k=2;k<=n-d;k++) coeff=coeff/k; return coeff; } float blenval() { int k; float blend; blend=compco(); for(k=1;k<=d;k++) blend=blend*u; for(k=1;k<=n-d;k++) blend=blend*(1.0-u); return blend; } void bezier() { float blend1; bx[j]=0;by[j]=0; for(d=0;d<=n;d++) { blend1=blenval(); bx[j]+=a[d]*blend1; by[j]+=b[d]*blend1; } } void curve() { for(j=0;j