#include "defs.h" /* * Find another point with the same position. * * h = item head * z = 'e' entry to be checked * return = first point with the same coordinates as z but that * is not z, 0 if none */ DL another(h, t, z) REG DL h, z; { REG DL p; p=h; while(p=nexta(h->type,p)) { if((p->type == t) && xysame(p, z) && (p != z)) return(p); } return(nil(DL)); } /* * Compute maximum x/y values * * h = head item * return = max position, 0 if empty shape */ DL maxpt(h) DL h; { OWN DL1 maxp; REG DL p; maxp->x = maxp->y = 0; p=h; while(p=nexta(h->type,p)) { switch(p->type) { case 'x': case 'h': case 'v': case 'V': break; default: if (p->x > maxp->x) maxp->x = p->x; if (p->y > maxp->y) maxp->y = p->y; } } return(maxp->x ? (maxp) : nil(DL)); } /* * Compute minimum x/y values * * h = head item * return = min position, 0 if empty shape */ LOC DL1 minp; DL minpt(h) REG DL h; { REG DL p; minp->x = minp->y = MAXINT; p=h; while(p=nexta(h->type,p)) { switch(p->type) { case 'x': case 'h': case 'v': case 'V': break; default: if(p->x < minp->x) minp->x = p->x; if(p->y < minp->y) minp->y = p->y; } } return((minp->x == MAXINT) ? nil(DL) : minp); } /* * linear displacement from given point * displacement is display image distance. * * p = base position * xoff = x increment * yoff = y increment */ DL roffset(p, xoff, yoff) DL p; INT xoff, yoff; { return(offset(p, xoff >> gscale, yoff >> gscale)); }