#include "defs.h" /* * Modify the extent entry of a shape definition to reflect * the current limits of the figure. * * h = 'L' entry * return = updated 'x' entry */ setext(h) DL h; { DL pext; REG DL p, q, r; DL mq; INT xfnd=0; chkhd(h, "L"); pext = fixext(h); if((r = extent()) && (mq = minpt(h))){ q=h; while(p=nexta('L', q)){ if(p->type != 'x'){ p->x = scale(p->x - mq->x, r->x, pext->x) + mq->x; p->y = scale(p->y - mq->y, r->y, pext->y) + mq->y; q=p; } elif(xfnd++) { delete(p); p=q; } else q=p; } } else error("cannot set extent"); } DL fixext(h) DL h; { REG DL pxx, pmin, pmax; pxx = succ('x', h); if((pmin = minpt(h)) && (pmax = maxpt(h))){ pxx->x = pmax->x - pmin->x; pxx->y = pmax->y - pmin->y; } return(pxx); } markext(h) DL h; { DL pext; DL p; DL1 p1; pext = succ('x', h); if (cursor(p1)==SP) { p = newdlw(AFTER, pext, 'X', 0, p1, 0); if ((p = succa(p)) && p->type == 'X') delete(p); } if ((p = succa(pext)) && p->type == 'X') wchar(p, 'X'); } /* * Compute a modified shape extent ('x' entry). * * input = two cursor positions identifying the opposite corners of the extent * return = position or 0 if not acknowledged */ DL extent() { DL1 p1, p2; markarea(p1, p2); return(point(abs(p1->x - p2->x), abs(p1->y - p2->y))); }