ravi@eneevax.UUCP (Ravi Kulkarni) (08/26/85)
Here are a few graphics demos that I ported from the sun. They run fine on my monochrome monitor, but I haven't tried it with a color monitor. I would imagine that they will run but without any color. You need the DR C development system or other c compiler with the gem bindings. No fancy windowing but they show the graphics capability of the ST very nicely. ------------------------------------------------------------------------- : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting qix.inp' sed 's/^X//' <<'//go.sysin dd *' >qix.inp [u] qix.68k=apstart,qix,aesbind,vdibind,osbind //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 qix.inp /bin/echo -n ' '; /bin/ls -ld qix.inp fi /bin/echo 'Extracting qix.c' sed 's/^X//' <<'//go.sysin dd *' >qix.c #include <osbind.h> #define Chance 80 #define Div 5 #define Diff 4 #define Max 20 #define Nqix 50 #define abs(x) ((x)<0?(-(x)):(x)) int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256]; int i,evwhich,dummy,rand,handle; int xstart,ystart,xwidth,ywidth,xcen,ycen; int pxy[4],mx; long Randx=1; main() { /* Set the system up to do GEM calls */ appl_init(); /* Get the handle of the desktop */ handle=graf_handle(&dummy,&dummy,&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); draw_sample(); v_clsvwk(handle); /* Release GEM calls */ appl_exit(); } draw_sample() { int temp[4], rgb_in[4], iter, loop; int dx0, dy0, dx1, dy1; int x0[Nqix], x1[Nqix], y0[Nqix], y1[Nqix]; int flag; v_clrwk(handle); vswr_mode(handle,3); Srand( (long) Gettime()); i=0; flag=0; dx0=5; dy0=2; dx1= -4; dy1=3; x0[0] = (int)(xwidth/3); y0[0] = (int)(ywidth/3); x1[0] = (int)(2*xwidth/3); y1[0] = (int)(2*ywidth/3); while (!Bconstat(2)){ if (flag) Vector( x0[i], y0[i], x1[i], y1[i]); Vector( bounce(x0, i, &dx0, xwidth-1), bounce(y0, i, &dy0, ywidth-1), bounce(x1, i, &dx1, xwidth-1), bounce(y1, i, &dy1, ywidth-1)); if (++i >= Nqix) { i=0; flag=1; } } Vector(x0[i], y0[i], x1[i], y1[i]); for(flag=(i+1)%Nqix;flag!=i;flag=(flag+1)%Nqix) Vector(x0[flag], y0[flag], x1[flag], y1[flag]); } Srand(x) long x; { Randx = x; } Rand() { return((Randx = Randx * 505360173 + 907633385) & 0x7fffffff); } bounce (x, off, dx, lim) int *x, off, *dx, lim; { int j,t1,t2; t1 = (long) Rand(); t2 = (long) Rand(); if (t1%100 > Chance) *dx = *dx + t2%Diff-Diff/2; if(*dx > Max || *dx < -Max) *dx = *dx / Div; j = *dx + x[(off+Nqix-1)%Nqix]; if (j > lim) { j = lim; *dx = -(*dx); } else if (j < 0) { j = 0; *dx = -(*dx); } return (x[off] = j); } 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); } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 qix.c /bin/echo -n ' '; /bin/ls -ld qix.c fi /bin/echo 'Extracting qux.inp' sed 's/^X//' <<'//go.sysin dd *' >qux.inp [u] qux.68k=apstart,qux,aesbind,vdibind,osbind //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 qux.inp /bin/echo -n ' '; /bin/ls -ld qux.inp fi /bin/echo 'Extracting qux.c' sed 's/^X//' <<'//go.sysin dd *' >qux.c #include <osbind.h> #define Queues 4 #define Nqux 32 #define abs(x) ((x)<0?(-(x)):(x)) int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256]; int i,evwhich,dummy,rand,handle; int xstart,ystart,xwidth,ywidth,xcen,ycen; int pxy[4],mx; long Randx = 1; int width,height; main() { /* Set the system up to do GEM calls */ appl_init(); /* Get the handle of the desktop */ handle=graf_handle(&width,&height,&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]; /* vs_clip(handle,1,pxy); */ graf_mouse(0,i); draw_sample(); v_clsvwk(handle); /* Release GEM calls */ appl_exit(); } draw_sample() { int Dx[Queues], Dy[Queues]; int x[Queues][Nqux], y[Queues][Nqux]; int i=0, flag=0; v_clrwk(handle); vswr_mode(handle,3); Srand((long) Gettime()); for(i=0;i<Queues;i++) { Dx[i]=(long) Rand3(); Dy[i]=(long) Rand3(); } x[0][Nqux-1] = (int)(xwidth/3); y[0][Nqux-1] = (int)(ywidth/3); x[1][Nqux-1] = (int)(2*xwidth/3); y[1][Nqux-1] = (int)(2*ywidth/3); x[2][Nqux-1] = (int)(xwidth/3); y[2][Nqux-1] = (int)(2*ywidth/3); x[3][Nqux-1] = (int)(2*xwidth/3); y[3][Nqux-1] = (int)(ywidth/3); i=0; while (!Bconstat(2)){ if (flag) { Vector (x[0][i], y[0][i], x[1][i], y[1][i]); Vector (x[1][i], y[1][i], x[2][i], y[2][i]); Vector (x[2][i], y[2][i], x[3][i], y[3][i]); Vector (x[1][i], y[1][i], x[3][i], y[3][i]); Vector (x[3][i], y[3][i], x[0][i], y[0][i]); Vector (x[2][i], y[2][i], x[0][i], y[0][i]); } Vector (bounce (x[0], i, Dx+0, xwidth-1), bounce (y[0], i, Dy+0, ywidth-1), bounce (x[1], i, Dx+1, xwidth-1), bounce (y[1], i, Dy+1, ywidth-1)); Vector (bounce (x[2], i, Dx+2, xwidth-1), bounce (y[2], i, Dy+2, ywidth-1), bounce (x[3], i, Dx+3, xwidth-1), bounce (y[3], i, Dy+3, ywidth-1)); Vector (x[1][i], y[1][i], x[2][i], y[2][i]); Vector (x[1][i], y[1][i], x[3][i], y[3][i]); Vector (x[3][i], y[3][i], x[0][i], y[0][i]); Vector (x[2][i], y[2][i], x[0][i], y[0][i]); if (++i >= Nqux) { i=0; flag=1; } } Vector (x[0][i], y[0][i], x[1][i], y[1][i]); Vector (x[1][i], y[1][i], x[2][i], y[2][i]); Vector (x[2][i], y[2][i], x[3][i], y[3][i]); Vector (x[1][i], y[1][i], x[3][i], y[3][i]); Vector (x[3][i], y[3][i], x[0][i], y[0][i]); Vector (x[2][i], y[2][i], x[0][i], y[0][i]); for(flag=(i+1)%Nqux;flag!=i;flag=(flag+1)%Nqux) { Vector (x[0][flag], y[0][flag], x[1][flag], y[1][flag]); Vector (x[1][flag], y[1][flag], x[2][flag], y[2][flag]); Vector (x[2][flag], y[2][flag], x[3][flag], y[3][flag]); Vector (x[1][flag], y[1][flag], x[3][flag], y[3][flag]); Vector (x[3][flag], y[3][flag], x[0][flag], y[0][flag]); Vector (x[2][flag], y[2][flag], x[0][flag], y[0][flag]); } } Srand(x) long x; { Randx = x; } Rand() { return((Randx = Randx * 505360173 + 907633385) & 0x7fffffff); } Rand2() { return(Rand()>>13); } Rand3() { return(((Randx = Randx * 505360173 + 907633385)>>13)&1 ? ((((Randx = Randx * 505360173 + 907633385)>>13)&1)+1) : -((((Randx = Randx * 505360173 + 907633385)>>13)&1)+1)); } bounce (x, off, dx, lim) int *x, off, *dx, lim; { int j; j = *dx + x[!off ? Nqux-1 : off-1]; if (j > lim) { j = lim; *dx = -(*dx); } else if (j < 1) { j = 1; *dx = -(*dx); } return(x[off] = j); } 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); } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 qux.c /bin/echo -n ' '; /bin/ls -ld qux.c fi -- ARPA: eneevax!ravi@maryland UUCP: [seismo,allegra]!umcp-cs!eneevax!ravi