void resize(void) { Rectangle old, r; int dxo, dyo, dxn, dyn; Win *w; old = screen->r; dxo = Dx(old); dyo = Dy(old); if(getwindow(display, Refnone) < 0) sysfatal("resize failed: %r"); dxn = Dx(screen->r); dyn = Dy(screen->r); freescreen(scr); scr = allocscreen(screen, display->white, 0); if(scr == nil) sysfatal("allocscreen: %r"); for(w = wlist.next; w != &wlist; w = w->next){ r = rectsubpt(w->entire, old.min); r.min.x = muldiv(r.min.x, dxn, dxo); r.max.x = muldiv(r.max.x, dxn, dxo); r.min.y = muldiv(r.min.y, dyn, dyo); r.max.y = muldiv(r.max.y, dyn, dyo); w->entire = rectaddpt(r, screen->r.min); w->inner = insetrect(w->entire, BORDSIZ); freeimage(w->im); w->im = allocwindow(scr, w->entire, Refbackup, 0); if(w->im == nil) sysfatal("allocwindow: %r"); draw(w->im, w->inner, w->tab->cols[BACK], nil, ZP); border(w->im, w->entire, BORDSIZ, w->tab->cols[w == actw ? BORD : DISB], ZP); w->tab->draw(w); } }
void grabmouse(void*) { int fd, x, y; char ibuf[256], obuf[256]; if(debug) return; fd = open("/dev/mouse", ORDWR); if(fd < 0) error("can't open /dev/mouse: %r"); snprint(obuf, sizeof obuf, "m %d %d", screen->r.min.x + Dx(screen->r)/2, screen->r.min.y + Dy(screen->r)/2); while(read(fd, ibuf, sizeof ibuf) > 0){ ibuf[12] = 0; ibuf[24] = 0; x = atoi(ibuf+1); y = atoi(ibuf+13); if(x != screen->r.min.x + Dx(screen->r)/2 || y != screen->r.min.y + Dy(screen->r)/2){ fprint(fd, "%s", obuf); doblank = 1; } } }
Point pix2board(int x, int y) { float d, rx, ry, yh; int ny, nx; /* XXX: float→int causes small rounding errors */ d = (float)(Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) -20: Dx(screen->r)-20; rx = d/(float)SzX; rx = rx/2.0; ry =d/(float)SzY; ry = ry/2.0; yh = ry/3.73205082; /* reverse board2pix() */ ny = (int)(((float)y - ry)/(2*ry - ((y>2*ry)?yh:0.0)) + 0.5); /* ny = (y - ry)/(2ry-yh) */ nx = (int)(((float)x - rx - (ny%2?rx:0.0))/(rx*2.0) + 0.5); /* nx = (x - rx - rx)/2rx */ if (nx >= SzX) nx = SzX-1; if (ny >=SzY) ny = SzY-1; return Pt(nx, ny); }
void rowresize(Row *row, Rectangle r) { int i, dx, odx; Rectangle r1, r2; Column *c; dx = Dx(r); odx = Dx(row->r); row->r = r; r1 = r; r1.max.y = r1.min.y + font->height; textresize(&row->tag, screen, r1); r1.min.y = r1.max.y; r1.max.y += Border; draw(screen, r1, display->black, nil, ZP); r.min.y = r1.max.y; r1 = r; r1.max.x = r1.min.x; for(i=0; i<row->ncol; i++){ c = row->col[i]; r1.min.x = r1.max.x; if(i == row->ncol-1) r1.max.x = r.max.x; else r1.max.x = r1.min.x+Dx(c->r)*dx/odx; if(i > 0){ r2 = r1; r2.max.x = r2.min.x+Border; draw(screen, r2, display->black, nil, ZP); r1.min.x = r2.max.x; } colresize(c, r1); } }
void tkcvsrectdraw(Image *img, TkCitem *i, TkEnv *pe) { int lw, rw; TkEnv *e; TkCrect *r; Rectangle d, rr; Point tr, bl; Image *pen; USED(pe); d.min = i->p.drawpt[0]; d.max = i->p.drawpt[1]; e = i->env; r = TKobj(TkCrect, i); pen = nil; if((e->set & (1<<TkCfill))) pen = tkgc(e, TkCfill); if(pen != nil) draw(img, d, pen, r->stipple, d.min); tr.x = d.max.x; tr.y = d.min.y; bl.x = d.min.x; bl.y = d.max.y; rw = (TKF2I(r->width) + 1)/2; if(rw <= 0) return; lw = (TKF2I(r->width))/2; pen = tkgc(e, TkCforegnd); if(pen != nil) { /* horizontal lines first */ rr.min.x = d.min.x - lw; rr.max.x = d.max.x + rw; rr.min.y = d.min.y - lw; rr.max.y = d.min.y + rw; draw(img, rr, pen, nil, rr.min); rr.min.y += Dy(d); rr.max.y += Dy(d); draw(img, rr, pen, nil, rr.min); /* now the vertical */ /* horizontal lines first */ rr.min.x = d.min.x - lw; rr.max.x = d.min.x + rw; rr.min.y = d.min.y + rw; rr.max.y = d.max.y - lw; draw(img, rr, pen, nil, rr.min); rr.min.x += Dx(d); rr.max.x += Dx(d); draw(img, rr, pen, nil, rr.min); } }
/* * A draw operation that touches only the area contained in bot but not in top. * mp and sp get aligned with bot.min. */ static void gendrawdiff(Image *dst, Rectangle bot, Rectangle top, Image *src, Point sp, Image *mask, Point mp, int op) { Rectangle r; Point origin; Point delta; USED(op); if(Dx(bot)*Dy(bot) == 0) return; /* no points in bot - top */ if(rectinrect(bot, top)) return; /* bot - top ≡ bot */ if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){ gendrawop(dst, bot, src, sp, mask, mp, op); return; } origin = bot.min; /* split bot into rectangles that don't intersect top */ /* left side */ if(bot.min.x < top.min.x){ r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y); delta = subpt(r.min, origin); gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); bot.min.x = top.min.x; } /* right side */ if(bot.max.x > top.max.x){ r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y); delta = subpt(r.min, origin); gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); bot.max.x = top.max.x; } /* top */ if(bot.min.y < top.min.y){ r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y); delta = subpt(r.min, origin); gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); bot.min.y = top.min.y; } /* bottom */ if(bot.max.y > top.max.y){ r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y); delta = subpt(r.min, origin); gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); bot.max.y = top.max.y; } }
void redraw(Image *screen) { Rectangle r = Rect(0,0,Dx(screen->r), Dy(screen->r)); catoffs.x=(Dx(r)-CATWID)/2; catoffs.y=(Dy(r)-CATHGT)/2; if(!ptinrect(catoffs, r)) fprint(2, "catclock: window too small, resize!\n"); xredraw=1; }
static int mga4xxscroll(VGAscr *scr, Rectangle dr, Rectangle sr) { uchar * mga; int pitch; int width, height; ulong start, end, sgn; Point sp, dp; if(scr->mmio == 0) return 0; mga = (uchar*)scr->mmio; assert(Dx(sr) == Dx(dr) && Dy(sr) == Dy(dr)); sp = sr.min; dp = dr.min; if(eqpt(sp, dp)) return 1; pitch = Dx(scr->gscreen->r); width = Dx(sr); height = Dy(sr); sgn = 0; if(dp.y > sp.y && dp.y < sp.y + height){ sp.y += height - 1; dp.y += height - 1; sgn |= SGN_UP; } width--; start = end = sp.x + (sp.y * pitch); if(dp.x > sp.x && dp.x < sp.x + width){ start += width; sgn |= SGN_LEFT; } else end += width; mga_fifo(mga, 8); mgawrite32(mga, DWGCTL, 0); mgawrite32(mga, SGN, sgn); mgawrite32(mga, AR5, sgn & SGN_UP ? -pitch : pitch); mgawrite32(mga, AR0, end); mgawrite32(mga, AR3, start); mgawrite32(mga, FXBNDRY, ((dp.x + width) << 16) | dp.x); mgawrite32(mga, YDSTLEN, (dp.y << 16) | height); mgawrite32(mga, DWGCTL + GO, DWG_BITBLT | DWG_SHIFTZERO | DWG_BFCOL | DWG_REPLACE); while(mgaread32(mga, STATUS) & 0x00010000) ; return 1; }
void drawnowin(int i) { Rectangle r; r = Rect(0,0,(Dx(screen->r)-2*MARGIN+PAD)/cols-PAD, font->height); r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows), MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min); draw(screen, insetrect(r, -1), lightblue, nil, ZP); }
void resize(void) { int fd, size = (Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) + 20 : Dx(screen->r)+20; fd = open("/dev/wctl", OWRITE); if(fd >= 0){ fprint(fd, "resize -dx %d -dy %d", size, size); close(fd); } }
void drawbar(void) { int i, j; int p; char buf[400], bar[200]; static char lastbar[200]; if(n > d || n < 0 || d <= 0) return; i = (Dx(rbar)*n)/d; p = (n*100LL)/d; if(textmode){ if(Dx(rbar) > 150){ rbar.min.x = 0; rbar.max.x = 150; return; } bar[0] = '|'; for(j=0; j<i; j++) bar[j+1] = '#'; for(; j<Dx(rbar); j++) bar[j+1] = '-'; bar[j++] = '|'; bar[j++] = ' '; sprint(bar+j, "%3d%% ", p); for(i=0; bar[i]==lastbar[i] && bar[i]; i++) ; memset(buf, '\b', strlen(lastbar)-i); strcpy(buf+strlen(lastbar)-i, bar+i); if(buf[0]) write(1, buf, strlen(buf)); strcpy(lastbar, bar); return; } if(lastp == p && last == i) return; if(lastp != p){ sprint(buf, "%d%%", p); stringbg(screen, addpt(screen->r.min, Pt(Dx(rbar)-30, 4)), text, ZP, display->defaultfont, buf, light, ZP); lastp = p; } if(last != i){ draw(screen, Rect(rbar.min.x+last, rbar.min.y, rbar.min.x+i, rbar.max.y), dark, nil, ZP); last = i; } flushimage(display, 1); }
Column* rowadd(Row *row, Column *c, int x) { Rectangle r, r1; Column *d; int i; d = nil; r = row->r; r.min.y = row->tag.r.max.y+Border; if(x<r.min.x && row->ncol>0){ /*steal 40% of last column by default */ d = row->col[row->ncol-1]; x = d->r.min.x + 3*Dx(d->r)/5; } /* look for column we'll land on */ for(i=0; i<row->ncol; i++){ d = row->col[i]; if(x < d->r.max.x) break; } if(row->ncol > 0){ if(i < row->ncol) i++; /* new column will go after d */ r = d->r; if(Dx(r) < 100) return nil; draw(screen, r, display->white, nil, ZP); r1 = r; r1.max.x = min(x, r.max.x-50); if(Dx(r1) < 50) r1.max.x = r1.min.x+50; colresize(d, r1); r1.min.x = r1.max.x; r1.max.x = r1.min.x+Border; draw(screen, r1, display->black, nil, ZP); r.min.x = r1.max.x; } if(c == nil){ c = emalloc(sizeof(Column)); colinit(c, r); incref(&reffont); }else colresize(c, r); c->row = row; c->tag.row = row; row->col = realloc(row->col, (row->ncol+1)*sizeof(Column*)); memmove(row->col+i+1, row->col+i, (row->ncol-i)*sizeof(Column*)); row->col[i] = c; row->ncol++; clearmouse(); return c; }
static void boxboxresize(Group *g, Rectangle r) { int rows, cols, ht, wid, i, hpad, wpad; Rectangle rr; if(debug) fprint(2, "boxboxresize %q %R (%d×%d) min/max %R separation %d\n", g->name, r, Dx(r), Dy(r), g->size, g->separation); ht = 0; for(i=0; i<g->nkids; i++){ if (g->kids[i]->size.min.y > ht) ht = g->kids[i]->size.min.y; } if (ht == 0) ctlerror("boxboxresize: height"); rows = Dy(r) / (ht+g->separation); hpad = (Dy(r) % (ht+g->separation)) / g->nkids; cols = (g->nkids+rows-1)/rows; wid = Dx(r) / cols - g->separation; for(i=0; i<g->nkids; i++){ if (g->kids[i]->size.max.x < wid) wid = g->kids[i]->size.max.x; } for(i=0; i<g->nkids; i++){ if (g->kids[i]->size.min.x > wid) wid = g->kids[i]->size.min.x; } if (wid > Dx(r) / cols) ctlerror("can't fit controls in boxbox"); wpad = (Dx(r) % (wid+g->separation)) / g->nkids; rr = rectaddpt(Rect(0,0,wid, ht), addpt(r.min, Pt(g->separation/2, g->separation/2))); if(debug) fprint(2, "boxboxresize rows %d, cols %d, wid %d, ht %d, wpad %d, hpad %d\n", rows, cols, wid, ht, wpad, hpad); for(i=0; i<g->nkids; i++){ if(debug) fprint(2, " %d %q: %R (%d×%d)\n", i, g->kids[i]->name, rr, Dx(rr), Dy(rr)); _ctlprint(g->kids[i], "rect %R", rectaddpt(rr, Pt((wpad+wid+g->separation)*(i/rows), (hpad+ht+g->separation)*(i%rows)))); } g->nseparators = rows + cols - 2; g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle)); rr = r; rr.max.y = rr.min.y + g->separation+hpad; for (i = 1; i < rows; i++){ g->separators[i-1] = rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation-hpad)); if(debug) fprint(2, "row separation %d [%d]: %R\n", i, i-1, rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation))); } rr = r; rr.max.x = rr.min.x + g->separation+wpad; for (i = 1; i < cols; i++){ g->separators[i+rows-2] = rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation-wpad, 0)); if(debug) fprint(2, "col separation %d [%d]: %R\n", i, i+rows-2, rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation, 0))); } }
void geometry(void) { int i, rows; Rectangle r; rows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD); r = Rect(0,0,(Dx(screen->r)-2*MARGIN), font->height); for(i=0; i<nmap; i++) map[i].r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows), MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min); }
int sub_image (imageptr iptr, regionptr rptr, imageptr *optr) { int nx,ny,nz, nx1,ny1,nz1, ix,iy,iz, ix0,iy0,iz0; size_t np, np1; nx = Nx(iptr); ny = Ny(iptr); nz = Nz(iptr); np = nx*ny*nz; /* grab the bounding box */ ix0 = BLC(rptr)[0]; iy0 = BLC(rptr)[1]; iz0 = BLC(rptr)[2]; nx1 = TRC(rptr)[0] - ix0; ny1 = TRC(rptr)[1] - iy0; nz1 = TRC(rptr)[2] - iz0; np1 = nx1*ny1*nz1; *optr = (imageptr ) allocate(sizeof(image)); dprintf (DLEV,"copy_image:Allocated image @ %d size=%d * %d * %d",*optr,nx1,ny1,nz1); Frame(*optr) = (real *) allocate(np1*sizeof(real)); dprintf (DLEV,"Frame allocated @ %d ",Frame(*optr)); Nx(*optr) = nx1; Ny(*optr) = ny1; Nz(*optr) = nz1; Xmin(*optr) = Xmin(iptr) + ix0*Dx(iptr); Ymin(*optr) = Ymin(iptr) + iy0*Dy(iptr); Zmin(*optr) = Zmin(iptr) + iz0*Dz(iptr); Dx(*optr) = Dx(iptr); Dy(*optr) = Dy(iptr); Dz(*optr) = Dz(iptr); Namex(*optr) = mystrcpy(Namex(iptr)); Namey(*optr) = mystrcpy(Namey(iptr)); Namez(*optr) = mystrcpy(Namez(iptr)); Xref(*optr) = Xref(iptr) + ix0; Yref(*optr) = Yref(iptr) + iy0; Zref(*optr) = Zref(iptr) + iz0; for (iz=0; iz<nz1; iz++) for (iy=0; iy<ny1; iy++) for (ix=0; ix<nx1; ix++) CubeValue(*optr,ix,iy,iz) = CubeValue(iptr,ix-ix0,iy-iy0,iz-iy0); Storage(*optr) = matdef[idef]; Axis(*optr) = Axis(iptr); set_iarray(*optr); return 1; /* succes return code */ }
void textredraw(Text *t, Rectangle r, Font *f, Image *b, int odx) { int maxt; Rectangle rr; frinit(t, r, f, b, t->Frame.cols); rr = t->r; rr.min.x -= Scrollwid+Scrollgap; /* back fill to scroll bar */ draw(t->b, rr, t->cols[BACK], nil, ZP); /* use no wider than 3-space tabs in a directory */ maxt = maxtab; if(t->what == Body){ if(t->w->isdir) maxt = min(TABDIR, maxtab); else maxt = t->tabstop; } t->maxtab = maxt*stringwidth(f, "0"); if(t->what==Body && t->w->isdir && odx!=Dx(t->all)){ if(t->maxlines > 0){ textreset(t); textcolumnate(t, t->w->dlp, t->w->ndl); textshow(t, 0, 0, 1); } }else{ textfill(t); textsetselect(t, t->q0, t->q1); } }
nemo_main() { int n = 0; setparams(); /* set globals */ instr = stropen (infile, "r"); plinit ("***", 0.0, 20.0, 0.0, 20.0); /* init yapp */ while (read_image(instr,&iptr)) { /* loop while more images found */ dprintf(1,"Time= %g MinMax= %g %g\n",Time(iptr),MapMin(iptr),MapMax(iptr)); nx=Nx(iptr); ny=Ny(iptr); nz=Nz(iptr); if (nz > 1) error("Cannot handle 3D images [%d,%d,%d]",nx,ny,nz); xmin=Xmin(iptr); ymin=Ymin(iptr); dx=Dx(iptr); dy=Dy(iptr); xsize = nx * dx; ysize = ny * dy; if (n>0) { sleep(1); plframe(); } plot_map(); /* plot the map */ n++; } plstop(); /* end of yapp */ strclose(instr); }
void tkcvssh(Tk *tk) { int top, bot, width; TkCanvas *c = TKobj(TkCanvas, tk); char val[Tkminitem], cmd[Tkmaxitem], *v, *e; if(c->xscroll == nil) return; top = 0; bot = TKI2F(1); width = Dx(c->region); if(width != 0) { top = TKI2F(c->view.x)/width; bot = TKI2F(c->view.x+tk->act.width)/width; } v = tkfprint(val, top); *v++ = ' '; tkfprint(v, bot); snprint(cmd, sizeof(cmd), "%s %s", c->xscroll, val); e = tkexec(tk->env->top, cmd, nil); if ((e != nil) && (tk->name != nil)) print("tk: xscrollcommand \"%s\": %s\n", tk->name->name, e); }
// constructive heuristics for orthogonal representation OR void LongestPathCompaction::constructiveHeuristics( PlanRep &PG, OrthoRep &OR, const RoutingChannel<int> &rc, GridLayoutMapped &drawing) { OGDF_ASSERT(OR.isOrientated()); // x-coordinates of vertical segments CompactionConstraintGraph<int> Dx(OR, PG, odEast, rc.separation()); Dx.insertVertexSizeArcs(PG, drawing.width(), rc); NodeArray<int> xDx(Dx.getGraph(), 0); computeCoords(Dx, xDx); // y-coordinates of horizontal segments CompactionConstraintGraph<int> Dy(OR, PG, odNorth, rc.separation()); Dy.insertVertexSizeArcs(PG, drawing.height(), rc); NodeArray<int> yDy(Dy.getGraph(), 0); computeCoords(Dy, yDy); // final coordinates of vertices for(node v : PG.nodes) { drawing.x(v) = xDx[Dx.pathNodeOf(v)]; drawing.y(v) = yDy[Dy.pathNodeOf(v)]; } }
/* * GCs are all for same screen, and depth is either 1 or screen depth. * Return a GC for the depth of b, with values as specified by gcv. * * Also, set (or unset) the clip rectangle if necessary. * (This implementation should be improved if setting a clip rectangle is not rare). */ GC _getgc(Bitmap *b, uint64_t gcvm, XGCValues *pgcv) { static GC gc0, gcn; static bool clipset = false; GC g; XRectangle xr; g = (b->ldepth==0)? gc0 : gcn; if(!g){ g = XCreateGC(_dpy, (Drawable)b->id, gcvm, pgcv); if(b->ldepth==0) gc0 = g; else gcn = g; } else XChangeGC(_dpy, g, gcvm, pgcv); if(b->flag&CLIP){ xr.x = b->clipr.min.x; xr.y = b->clipr.min.y; xr.width = Dx(b->clipr); xr.height = Dy(b->clipr); if(b->flag&SHIFT){ xr.x -= b->r.min.x; xr.y -= b->r.min.y; } XSetClipRectangles(_dpy, g, 0, 0, &xr, 1, YXBanded); clipset = true; }else if(clipset){ pgcv->clip_mask = None; XChangeGC(_dpy, g, GCClipMask, pgcv); clipset = false; } return g; }
void showpage(int page, Menu *m) { if(doc->fwdonly) m->lasthit = 0; /* this page */ else m->lasthit = reverse ? doc->npage-1-page : page; esetcursor(&reading); delayfreeimage(nil); im = cachedpage(doc, angle, page); if(im == nil) wexits(0); if(resizing) resize(Dx(im->r), Dy(im->r)); esetcursor(nil); if(showbottom){ ul.y = screen->r.max.y - Dy(im->r); showbottom = 0; } redraw(screen); flushimage(display, 1); }
void redraw(Image *screen) { Rectangle r; if(im == nil) return; ulrange.max = screen->r.max; ulrange.min = subpt(screen->r.min, Pt(Dx(im->r), Dy(im->r))); ul = pclip(ul, ulrange); drawop(screen, screen->r, im, nil, subpt(im->r.min, subpt(ul, screen->r.min)), S); if(im->repl) return; /* fill in any outer edges */ /* black border */ r = rectaddpt(im->r, subpt(ul, im->r.min)); border(screen, r, -2, display->black, ZP); r.min = subpt(r.min, Pt(2,2)); r.max = addpt(r.max, Pt(2,2)); /* gray for the rest */ if(gray == nil) { gray = xallocimage(display, Rect(0,0,1,1), RGB24, 1, 0x888888FF); if(gray == nil) { fprint(2, "g out of memory: %r\n"); wexits("mem"); } } border(screen, r, -4000, gray, ZP); // flushimage(display, 0); }
void ini_matrix(imageptr *iptr, int nx, int ny) { int ix,iy; printf ("iptr @ %d (sizeof = %d)\n",*iptr,sizeof(image)); if (*iptr==0) { *iptr = (imageptr ) allocate((sizeof(image))); printf ("allocated image 'iptr' @ %d\n",*iptr); Frame(*iptr) = (real *) allocate (nx*ny*sizeof(real)); printf ("Allocated frame @ %d\n",Frame(*iptr)); } else { printf ("Image already allocated @ %d\n",*iptr); printf ("with Frame @ %d\n",Frame(*iptr)); } Nx(*iptr) = nx; Ny(*iptr) = ny; Nz(*iptr) = 1; Xmin(*iptr) = 1.0; Ymin(*iptr) = 2.0; Zmin(*iptr) = 3.0; Dx(*iptr) = 0.1; Dy(*iptr) = 0.1; Dz(*iptr) = 0.1; Namex(*iptr) = NULL; /* no axis names */ Namey(*iptr) = NULL; Namez(*iptr) = NULL; Unit(*iptr) = NULL; /* no units */ Mask(*iptr) = NULL; set_iarray(*iptr); for (ix=0; ix<nx; ix++) for (iy=0; iy<ny; iy++) MapValue(*iptr,ix,iy) = (ix*ny+iy)*0.1; }
int textresize(Text *t, Rectangle r, int keepextra) { int odx; if(Dy(r) <= 0) r.max.y = r.min.y; else if(!keepextra) r.max.y -= Dy(r)%t->fr.font->height; odx = Dx(t->all); t->all = r; t->scrollr = r; t->scrollr.max.x = r.min.x+Scrollwid; t->lastsr = nullrect; r.min.x += Scrollwid+Scrollgap; frclear(&t->fr, 0); textredraw(t, r, t->fr.font, t->fr.b, odx); if(keepextra && t->fr.r.max.y < t->all.max.y && !t->fr.noredraw){ /* draw background in bottom fringe of window */ r.min.x -= Scrollgap; r.min.y = t->fr.r.max.y; r.max.y = t->all.max.y; draw(screen, r, t->fr.cols[BACK], nil, ZP); } return t->all.max.y; }
int movemouse(void) { mouse.xy = Pt(rboard.min.x + Dx(rboard)/2, rboard.min.y +Dy(rboard)/2); moveto(mousectl, mouse.xy); return mouse.xy.x; }
static int Rfmt(Fmt *f) { Rectangle r; r = va_arg(f->args, Rectangle); return fmtprint(f, "%P+%dx%d", r.min, Dx(r), Dy(r)); }
void nemo_main () { setparams(); /* set par's in globals */ instr = stropen (infile, "r"); read_image (instr,&iptr); /* set some global paramters */ nx = Nx(iptr); ny = Ny(iptr); nz = Nz(iptr); xmin = Xmin(iptr); ymin = Ymin(iptr); zmin = Zmin(iptr); dx = Dx(iptr); dy = Dy(iptr); dz = Dz(iptr); if(hasvalue("gauss")) make_gauss_beam(getparam("dir")); outstr = stropen (outfile,"w"); if (hasvalue("wiener")) wiener(); else smooth_it(); write_image (outstr,iptr); strclose(instr); strclose(outstr); }
/* make socket name from scriptname, switching / for _ */ static char * MakeSockName(char * scriptname ) { char * sockname; char * save; /* strict C compilers can't/won't do char foo[variant]; */ char *fullpath = my_malloc(path_max); int i = 0; if (realpath(scriptname, fullpath) == NULL) { perror("pperl: resolving full pathname to script failed"); exit(1); } Dx(Debug("realpath returned: %s\n", fullpath)); /* Ugh. I am a terrible C programmer! */ sockname = my_malloc(strlen(P_tmpdir) + strlen(fullpath) + 3); save = sockname; sprintf(sockname, "%s/", P_tmpdir); sockname += strlen(P_tmpdir) + 1; while (fullpath[i] != '\0') { if (fullpath[i] == '/') { *sockname = '_'; } else if (fullpath[i] == '.') { *sockname = '_'; } else { *sockname = fullpath[i]; } sockname++; i++; } *sockname = '\0'; free(fullpath); return save; }
static void renderchilds(Page *p) { Rectangle r; Kidinfo *k; Page *c; int i, j, x, y, *w, *h; draw(p->b, p->all, display->white, nil, ZP); r = p->all; y = r.min.y; c = p->child; k = p->kidinfo; frdims(k->rows, k->nrows, Dy(r), &h); frdims(k->cols, k->ncols, Dx(r), &w); for(i=0; i<k->nrows; i++){ x = r.min.x; for(j=0; j<k->ncols; j++){ if(c->aborting) return; c->b = p->b; c->all = Rect(x,y,x+w[j],y+h[i]); c->w = p->w; pagerender(c); c = c->next; x += w[j]; } y += h[i]; } free(w); free(h); }
void reshapewin(Window *w, Rectangle r) { assert(w->type == WWindow); assert(Dx(r) > 0 && Dy(r) > 0); /* Rather than an X error. */ configwin(w, r, w->border); }