void rect(int x1, int y1, int x2, int y2) { int temp; if(x1>x2) { temp=x1; x1=x2; x2=temp; } if(y1>y2) { temp=y1; y1=y2; y2=y1; } makeline(x1,y1,x1,y2); makeline(x1,y1,x2,y1); makeline(x1,y2,x2,y2); makeline(x2,y1,x2,y2); drawgrid(); }
/*-----------------------------------------------------------------------------------*/ static void savescript(void) { char line[40]; /* struct c64_fs_file f;*/ int f; f = cfs_open("@:config.cfg", CFS_WRITE); if(f == -1) { log_message("Could not open config.cfg", ""); return; } if(cfs[0] != 0) { int len = makeline(line, 'c',cfs); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'c', cfs)); } if(theme[0] != 0) { int len = makeline(line, 't',theme); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 't', theme)); } if(driver[0] != 0) { int len = makeline(line, 'n',driver); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'n', driver)); } if(ipaddr[0] != 0) { int len = makeline(line, 'i',ipaddr); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'i', ipaddr)); } if(netmask[0] != 0) { int len = makeline(line, 'm',netmask); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'm', netmask)); } if(gateway[0] != 0) { int len = makeline(line, 'r',gateway); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'r', gateway)); } if(dnsserver[0] != 0) { int len = makeline(line, 'd',dnsserver); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 'd', dnsserver)); } if(screensaver[0] != 0) { int len = makeline(line, 's',screensaver); cfs_write(f, line, len); // cfs_write(f, line, makeline(line, 's', screensaver)); } strcpy(line, ".\n\0\n\n\n"); cfs_write(f, line, strlen(line)); cfs_close(f); }
void drawvline(int x, int y, int y2, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, white); makeline(&quads[0], x + 1, y, x + 1, y2); glDrawArrays(GL_LINES, 0, 2); }
static int addtospan(struct span *sp, FILE *fp, int reset) { char *newl = NULL; size_t len, size = 0; if ((len = getline(&newl, &size, fp)) == -1) { if (ferror(fp)) eprintf("getline:"); else return 0; } if (reset) sp->nl = 0; if (sp->nl >= sp->maxl) { sp->lines = ereallocarray(sp->lines, (GROW * sp->maxl), sizeof(struct line *)); sp->maxl *= GROW; } sp->lines[sp->nl] = makeline(newl, len); sp->nl++; return 1; }
int main() { int type; scanf("%s",str); if (str[0]=='L') type=LEFT; else if (str[0]=='R') type=RIGHT; else if (str[0]=='C') type=CENTER; else type=JUSTIFY; scanf("%s",str); while (makeline()==1) { if (type==LEFT) left(); else if (type==RIGHT) right(); else if (type==CENTER) center(); else justify(); len=0; line[0]='\0'; } if (type==LEFT) left(); else if (type==RIGHT) right(); else if (type==CENTER) center(); else left(); return 0; }
// get a line passing between two points Line getmidline(point2d a, point2d b) { point2d mid(a+b); mid.x/=2; mid.y/=2; return rot90( makeline(a,b), mid ); }
//for segment segment intersection, check additionally //min(x1,x2) <= x <= max(x1,x2) //min(y1,y2) <= x <= max(y1,y2) bool segmentsIntersect( point2d A, point2d B, point2d C, point2d E ) { point2d in = intersect( makeline(A,B), makeline(C,E) ); return linePointDist(A,B,in,true) < eps && linePointDist(C,E,in,true) < eps; }
void checkgrid() { if(selectedwindow()==3) { int x1,x2,y1,y2; if(mousestat()==1) { if(selected(1,0)==0) { for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(x>=x1 && x<x2 && y>=y1 && y<y2) { graph[loopx][loopy]=selected(0,0); drawpixel(loopx,loopy); } } } thumb(); } } if(mousestat()==3) { if(selected(1,0)==2 || selected(1,0)==3) { for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(x>=x1 && x<x2 && y>=y1 && y<y2) { sx=loopx; sy=loopy; } } } } if(selected(1,0)==1) { for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(x>=x1 && x<x2 && y>=y1 && y<y2) { fillit(loopx,loopy,graph[loopx][loopy],selected(0,0)); drawgrid(); } } } } } if(mousestat()==4 && select==1) { if(selected(1,0)==2) { for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(x>=x1 && x<x2 && y>=y1 && y<y2) { ex=loopx; ey=loopy; makeline(sx,sy,ex,ey); drawgrid(); } } } } if(selected(1,0)==3) { for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(x>=x1 && x<x2 && y>=y1 && y<y2) { ex=loopx; ey=loopy; rect(sx,sy,ex,ey); drawgrid(); } } } } } } }
/* * parameters * * i: line number for deciding format * nl: line number for finding data usually identical */ void putline(int i, int nl) { int c, lf, ct, form, lwid, vspf, ip = -1, cmidx, exvspen, vforml; int vct, chfont; char *s, *size, *fn; watchout=vspf=exvspen=0; if (i==0) once=0; if (i==0 && ( allflg || boxflg || dboxflg)) fullwide(0, dboxflg? '=' : '-'); if (instead[nl]==0 && fullbot[nl] ==0) for(c=0; c<ncol; c++) { s = table[nl][c].col; if (s==0) continue; if (vspen(s)) { for(ip=nl; ip<nlin; ip=next(ip)) if (!vspen(s=table[ip][c].col)) break; if (s>(char *)0 && s<(char *)128) fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); continue; } if (point(s)) continue; fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); watchout=1; } if (linestop[nl]) fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1); lf = prev(nl); if (instead[nl]) { puts(instead[nl]); return; } if (fullbot[nl]) { switch (ct=fullbot[nl]) { case '=': case '-': fullwide(nl,ct); } return; } for(c=0; c<ncol; c++) { if (instead[nl]==0 && fullbot[nl]==0) if (vspen(table[nl][c].col)) vspf=1; if (lf>=0) if (vspen(table[lf][c].col)) vspf=1; } if (vspf) { fprintf(tabout, ".nr #^ \\n(\\*(#du\n"); fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */ } vspf=0; chfont=0; for(c=0; c<ncol; c++) { s = table[nl][c].col; if (s==0) continue; chfont |= (int)(font[stynum[nl]][c]); if (point(s) ) continue; lf=prev(nl); if (lf>=0 && vspen(table[lf][c].col)) fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c); else fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s); } if (allflg && once>0 ) fullwide(i,'-'); once=1; runtabs(i, nl); if (allh(nl) && !pr1403) { fprintf(tabout, ".nr %d \\n(.v\n", SVS); fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n"); } if (chfont) fprintf(tabout, ".nr %2d \\n(.f\n", S1); fprintf(tabout, ".nr 35 1m\n"); fprintf(tabout, "\\&"); vct = 0; for(c=0; c<ncol; c++) { if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0) { tohcol(c); drawvert(lf, i, c, lwid); vct += 2; } if (rightl && c+1==ncol) continue; vforml=i; for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) vforml= lf; form= ctype(vforml,c); if (form != 's') { ct = c+CLEFT; if (form=='a') ct = c+CMID; if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID; fprintf(tabout, "\\h'|\\n(%du'", ct); } s= table[nl][c].col; fn = font[stynum[vforml]][c]; size = csize[stynum[vforml]][c]; if (*size==0)size=0; switch(ct=ctype(vforml, c)) { case 'n': case 'a': if (table[nl][c].rcol) { if (lused[c]) /*Zero field width*/ { ip = prev(nl); if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); exvspen=1; } } fprintf(tabout, "%c%c",F1,F2); puttext(s,fn,size); fprintf(tabout, "%c",F1); } s= table[nl][c].rcol; form=1; break; } /* FALLTHROUGH */ case 'c': form=3; break; case 'r': form=2; break; case 'l': form=1; break; case '-': case '=': if (real(table[nl][c].col)) fprintf(stderr,gettext("%s: line %d: Data ignored on table line %d\n"), ifile, iline-1, i+1); makeline(i,c,ct); continue; default: continue; } if (realsplit ? rused[c]: used[c]) /*Zero field width*/ { /* form: 1 left, 2 right, 3 center adjust */ if (ifline(s)) { makeline(i,c,ifline(s)); continue; } if (filler(s)) { printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2); continue; } ip = prev(nl); cmidx = ctop[stynum[nl]][c]==0; if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } fprintf(tabout, "%c", F1); if (form!= 1) fprintf(tabout, "%c", F2); if (vspen(s)) vspf=1; else puttext(s, fn, size); if (form !=2) fprintf(tabout, "%c", F2); fprintf(tabout, "%c", F1); } if (ip>=0) if (vspen(table[ip][c].col)) { exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) && (topat[c] == topat[c+1]) && (cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0); if (exvspen==0) { fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } else exvspen=0; /* if lines need to be split for gcos here is the place for a backslash */ if (vct > 7 && c < ncol) { fprintf(tabout, "\n.sp-1\n\\&"); vct=0; } } fprintf(tabout, "\n"); if (allh(nl) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS); if (watchout) funnies(i,nl); if (vspf) { for(c=0; c<ncol; c++) if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col))) { fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c); topat[c]=nl; } } }