/* * weave - * A weaving simulator for IRIS workstations. This simulates * a loom and the pattern created with different settings of the headles * and various treadling patterns. The tieups are also programable. * Click the left mouse over the left area to change the treadling * pattern, Click the left mouse over the top area to change the * threading of the headles. Click the left mouse over the box in * the upper left corner to alter the tieups. * * To compile on IRIS 4D: * * cc weave.c -o weave -lgl_s * * Paul Haeberli and Amie Slate - 1991 */ #include "stdio.h" #include "gl.h" #include "device.h" /* feel free to change the number of treadles and headles */ #define NTREADLES (6) #define NHEADLES (4) #define BOXSIZE (8) #define TOTX (1200/BOXSIZE) #define TOTY (800/BOXSIZE) #define NX (TOTX-NTREADLES) #define NY (TOTY-NHEADLES) int up[NX]; int headles[NX]; int treadles[NY]; int tieup[NHEADLES][NTREADLES]; main() { short val; int x, y, menu; prefsize(TOTX*BOXSIZE,TOTY*BOXSIZE); winopen("weave"); qmouse(); RGBmode(); gconfig(); initstate(); makeframe(); menu = defpup("weave %t|init state|print help"); while(1) { switch(qread(&val)) { case REDRAW: makeframe(); break; case LEFTMOUSE: if(val) { x = getmousex()/BOXSIZE; y = getmousey()/BOXSIZE; if(x=NY) { y = y-NY; tieup[y][x] = 1-tieup[y][x]; makeframe(); } else { treadles[y] = x; updaterow(y); /* makeframe(); */ } } else if(y>=NY) { x = x-NTREADLES; headles[x] = y-NY; updatecol(x); /* makeframe(); */ } } break; case MENUBUTTON: if(val) { switch(dopup(menu)) { case 1: initstate(); makeframe(); break; case 2: printhelp(); break; } } } } } initstate() { int i, j; for(i=0; i