/* * see COPYRIGHT */ #include #include #include "bzscreen.h" /* * functions to draw the bezier curves in text mode */ double fmin(a,b) double a, b; { if(a cols || physy+yoff > rows) { fprintf(stderr, "*** drawable area out of screen\n"); exit(1); } if(minx>maxx || miny>maxy) { fprintf(stderr, "*** empty drawable area\n"); exit(1); } screen.physx = physx; screen.physy = physy; screen.rows = rows; screen.cols = cols+2; /* for '\n\0' */ screen.xoff = xoff; screen.yoff = yoff; screen.minx = minx; screen.miny = miny; if(( screen.dots=malloc(screen.rows*screen.cols) )==NULL) { perror("*** no memory for screen: "); exit(1); } j=screen.rows*screen.cols; for(i=0; i abs(bx-ax) ) { if(by>ay) markb='^'; else markb='v'; } else { if(bx>ax) markb='>'; else markb='<'; } if(dx==cx && dy==cy) { marke=mark; } else if( abs(dy-cy) > abs(dx-cx) ) { if(dy>cy) marke='^'; else marke='v'; } else { if(dx>cx) marke='>'; else marke='<'; } for(i=1; i=screen.physy || x<0 || x>=screen.physx) return; screendot(x,y)=mark; } void setabsdot(mark, x, y) int x, y, mark; { if(y<0 || y>=screen.rows || x<0 || x>=screen.cols-2) return; screenabsdot(x,y)=mark; } void setfdot(mark, fx, fy) int mark; double fx, fy; { int x, y; x=(int)(fx*screen.xscale+0.5); y=(int)(fy*screen.yscale+0.5); if(y<0 || y>=screen.physy || x<0 || x>=screen.physx) return; screendot(x,y)=mark; } /* destructive */ void printscreen(f) FILE *f; { int r; char *pi, *pc; for(r=screen.rows-1; r>=0; r--) { pc=&screenabsdot(0,r); for(pi=&screenabsdot(-2,r+1); pi>=pc && *pi == ' '; pi--) {} pi[1]='\n'; pi[2]=0; fputs(pc, f); } }