gyuri@eneevax.UUCP (Gyorgy Fekete) (08/30/85)
compile this, and link it with apstart, aesbind, vdibind, osbind, libf. ======================================================================= #include <osbind.h> #define NUMLINES 343 /* number of vectors in a design */ #define NUM_FUNCTIONS 13 /* number of functions */ /* This demo creates random vector designs. This is accomplished by randomly choosing a function for each coordinate halve of the two points describing a vector that moves through two dimensional space. Both x coordinate halves cannot be the same since the design would simply be a collection of vertical lines. Similarly both y coordinate halves cannot be the same. The values of the functions were pre computed to have the demo run as fast as possible. The program will terminate on any key press since it is in an endless loop. */ extern double cos(), sin(); int func[13][NUMLINES]; int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256]; int dummy,handle; int xwidth,ywidth,height,width; int pxy[4],t1,t2,t3,t4; int i,j,k,l,m; int mx; long Randx=1; main() { /* Set the system up to do GEM calls */ appl_init(); /* Get the handle of the desktop */ handle=graf_handle(&height,&width,&dummy,&dummy); /* Open the workstation. */ for(i=1; i<10; ++i) intin[i] = 1; intin[10] = 2; v_opnvwk(intin, &handle, intout); pxy[0]=0; pxy[1]=0; pxy[2]=intout[0]; pxy[3]=intout[1]; xwidth=pxy[2]; ywidth= pxy[3]; graf_mouse(0,i); v_clrwk(handle); v_gtext(handle,0,height*2,"Precomputing coefficients ... please wait"); init(); Srand((long) Gettime()); /* set the seed */ while(!Bconstat(2)){ /* Any keys pressed? (2 is keyboard)*/ v_clrwk(handle); i=Rand()%NUM_FUNCTIONS; while((j = Rand()%NUM_FUNCTIONS)==i); k=Rand()%NUM_FUNCTIONS; while((l = Rand()%NUM_FUNCTIONS)==k); /* only do NUMLINES-1 lines ... dont redraw first line */ for(m=0;m<NUMLINES;m++) { t1 = func[i][m]; t2 = (func[j][m]*40)/64; t3 = func[k][m]; t4 = (func[l][m]*40)/64; Vector(t1,t2,t3,t4); } for(t1=0;t1 <1000;t1++){ for(t2=0;t2 < 500;t2++); } } v_clsvwk(handle); /* Release GEM calls */ appl_exit(); } init() { int x; double pi,v1,v2,v3,v4; pi=3.1415927; v4 = NUMLINES; v1 = 2*pi/NUMLINES; v2=xwidth/2; for(x=0;x<NUMLINES;x++){ v3=x; func[0][x] = 2 * ( v3 - (v4/2) )*v2 /v4; if(func[0][x] < 0) func[0][x] = -func[0][x]; func[0][x]=func[0][x]+320; func[1][x] = sin( v1*v3 )*v2 + 320; func[2][x] = -sin( v1*v3 )*v2 + 320; func[3][x] = cos( v1*v3 )*v2 + 320; func[4][x] = -cos( v1*v3 )*v2 + 320; func[5][x] = sin( 2*v1*v3 )*v2 + 320; func[6][x] = -sin( 2*v1*v3 )*v2 + 320; func[7][x] = cos( 2*v1*v3 )*v2 + 320; func[8][x] = -cos( 2*v1*v3 )*v2 + 320; func[9][x] = sin( 3*v1*v3 )*v2 + 320; func[10][x] = -sin( 3*v1*v3 )*v2 + 320; func[11][x] = cos( 3*v1*v3 )*v2 + 320; func[12][x] = -cos( 3*v1*v3 )*v2 + 320; } } Vector(a,b,c,d) int a,b,c,d; { ptsin[0] = a; ptsin[1] = b; ptsin[2] = c; ptsin[3] = d; v_pline(handle, 2, ptsin); } Srand(x) long x; { Randx = x; } Rand() { /* * The mask is for getting a 15 bit value */ return((Randx = Randx * 505360173 + 907633385) & 0x00007fff); }