|
|
1.1 ! root 1: /* ! 2: %Z% %M% version %I% %Q%of %H% %T% ! 3: Last Delta: %G% %U% to %P% ! 4: */ ! 5: ! 6: #include "cip.h" ! 7: ! 8: extern int gridState; ! 9: ! 10: Point ! 11: near(p,h,offset) ! 12: Point p, offset; ! 13: struct thing *h; ! 14: { ! 15: register struct thing *t; ! 16: register int g; ! 17: register Point *s; ! 18: Point stickyPoint[9], found, q; ! 19: ! 20: p = sub(p,offset); ! 21: found.x=0; found.y=0; ! 22: t = (h==(struct thing *)NULL)?(struct thing *)NULL:h->next; ! 23: if (t != h) { ! 24: do { ! 25: if (ptinrect(p,inset(t->bb,-nearPT))) { ! 26: s = stickyPoint; ! 27: if (t->type!=ARC) { ! 28: *s++ = t->origin; ! 29: } ! 30: switch(t->type) { ! 31: case LINE: { ! 32: *s++ = t->otherValues.end; ! 33: *s++ = div(add(t->origin,t->otherValues.end),2); ! 34: break; ! 35: } ! 36: case MACRO: ! 37: case BOX: { ! 38: *s++ = t->bb.corner; ! 39: s->x = t->origin.x; ! 40: s->y = t->bb.corner.y; ! 41: s++; ! 42: s->x = t->bb.corner.x; ! 43: s->y = t->origin.y; ! 44: s++; ! 45: if (t->type==BOX) { ! 46: s->x = t->origin.x; ! 47: s->y = (t->origin.y + t->bb.corner.y)/2; ! 48: s++; ! 49: s->x = (t->origin.x + t->bb.corner.x)/2; ! 50: s->y = t->origin.y; ! 51: s++; ! 52: s->x = t->bb.corner.x; ! 53: s->y = (t->origin.y + t->bb.corner.y)/2; ! 54: s++; ! 55: s->x = (t->origin.x + t->bb.corner.x)/2; ! 56: s->y = t->bb.corner.y; ! 57: s++; ! 58: *s++ = div(add(t->origin,t->bb.corner),2); ! 59: } ! 60: break; ! 61: } ! 62: case CIRCLE: { ! 63: q.x = 0; ! 64: q.y = t->otherValues.radius; ! 65: *s++ = add(t->origin,q); ! 66: *s++ = sub(t->origin,q); ! 67: *s++ = add(t->origin,Pt(q.y,q.x)); ! 68: *s++ = sub(t->origin,Pt(q.y,q.x)); ! 69: break; ! 70: } ! 71: case ELLIPSE: { ! 72: q.y = t->otherValues.ellipse.ht>>1; ! 73: q.x = t->otherValues.ellipse.wid>>1; ! 74: *s++ = add(t->origin,Pt(0,q.y)); ! 75: *s++ = sub(t->origin,Pt(0,q.y)); ! 76: *s++ = add(t->origin,Pt(q.x,0)); ! 77: *s++ = sub(t->origin,Pt(q.x,0)); ! 78: break; ! 79: } ! 80: case SPLINE: { ! 81: *s++ = ! 82: t->otherValues.spline.plist[t->otherValues.spline.used]; ! 83: break; ! 84: } ! 85: case ARC: { ! 86: *s++ = t->otherValues.arc.start; ! 87: *s++ = t->otherValues.arc.end; ! 88: break; ! 89: } ! 90: } ! 91: for (g=0; g<(s-stickyPoint); g++) { ! 92: if (distance(p,stickyPoint[g])<nearPT) { ! 93: found = stickyPoint[g]; ! 94: } ! 95: } ! 96: } ! 97: if (found.x==0) { ! 98: t = t->next; ! 99: } ! 100: } while ((t != h)&&(found.x==0)); ! 101: } ! 102: if ((found.x==0) && (gridState==GRIDon)) { ! 103: found = sub(mul(div(add(p,offset),8),8),offset); ! 104: } ! 105: return( (found.x==0 && found.y==0) ? found : add(found,offset) ); ! 106: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.