home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part01 / lemelli.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  2.8 KB  |  100 lines

  1. /*
  2.  * lemselect.c - object selection and proximity testing
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. elliresize(i)
  10.     {
  11.     }
  12.  
  13. ellinearpt(i, x, y)
  14.     {
  15.     if (ptinrect(x, y, Oxl, Oyl, Oxh, Oyh, LINETOL))
  16.     {
  17.         if (dist(Ox,  Oyh, x, y) < ENDTOL) return(1);
  18.         if (dist(Ox,  Oyl, x, y) < ENDTOL) return(1);
  19.         if (dist(Oxl, Oy,  x, y) < ENDTOL) return(1);
  20.         if (dist(Oxh, Oy,  x, y) < ENDTOL) return(1);
  21.         if (dist(Ox,  Oy,  x, y) < ENDTOL) return(1);
  22.     }
  23.     return(0);
  24.     }
  25.  
  26. elliinrect(i, xl, yl, xh, yh)
  27.     {
  28.     return(objsupinrect(i, xl, yl, xh, yh));
  29.     }
  30.  
  31. ellicantug(i, x, y)
  32.     {
  33.     return(objsupcantug(i, x, y));
  34.     }
  35.  
  36. ellitug(i, xs, ys, xe, ye)
  37.     {
  38.     int n, s, e, w, c;
  39.     n = dist(Ox,  Oyh, xs, ys);
  40.     s = dist(Ox,  Oyl, xs, ys);
  41.     w = dist(Oxl, Oy,  xs, ys);
  42.     e = dist(Oxh, Oy,  xs, ys);
  43.     c = dist(Ox,  Oy,  xs, ys);
  44.     if (n<s && n<e && n<w && n<c) { if (Oys>Oye) Oys = ye; else Oye = ye; }
  45.     if (s<n && s<e && s<w && s<c) { if (Oys<Oye) Oys = ye; else Oye = ye; }
  46.     if (e<w && e<n && e<s && e<c) { if (Oxs>Oxe) Oxs = xe; else Oxe = xe; }
  47.     if (w<e && w<n && w<s && w<c) { if (Oxs<Oxe) Oxs = xe; else Oxe = xe; }
  48.     if (c<=n && c<=s && c<=e && c<=w) ellimove(i, xe-xs, ye-ys);
  49.     }
  50.  
  51. ellialign(i, x, y)
  52.     int *x, *y;
  53.     {
  54.     int n, s, e, w, c;
  55.     n = dist(Ox,  Oyh, *x, *y);
  56.     s = dist(Ox,  Oyl, *x, *y);
  57.     w = dist(Oxl, Oy,  *x, *y);
  58.     e = dist(Oxh, Oy,  *x, *y);
  59.     c = dist(Ox,  Oy,  *x, *y);
  60.     *x = Ox;
  61.     *y = Oy;
  62.     if (n<s && n<e && n<w && n<c) *y = Oyh;
  63.     if (s<n && s<e && s<w && s<c) *y = Oyl;
  64.     if (e<w && e<n && e<s && e<c) *x = Oxh;
  65.     if (w<=e && w<=n && w<=s && w<=c) *x = Oxl;
  66.     }
  67.  
  68. ellimove(i, x, y)
  69.     {
  70.     objsupmove(i, x, y);
  71.     }
  72.  
  73. elliaffine(i, m11, m12, m21, m22)
  74.     float m11, m12, m21, m22;
  75.     {
  76.     objsupaffine(i, m11, m12, m21, m22, 1);
  77.     }
  78.  
  79. ellidraw(i, col)
  80.     {
  81.     int wid, hw2, hh2, hw7, hh7;
  82.     wid = lemfont[Osizer].thick;
  83.     hw2 = ABS(Ow)/4;
  84.     hh2 = ABS(Oh)/4;
  85.     hw7 = ABS(Ow)*7/16;
  86.     hh7 = ABS(Oh)*7/16;
  87.     drawvec(Oxl,    Oy,     Ox-hw7, Oy+hh2, col, wid, Oemph);
  88.     drawvec(Ox-hw7, Oy+hh2, Ox-hw2, Oy+hh7, col, wid, Oemph);
  89.     drawvec(Ox-hw2, Oy+hh7, Ox,     Oyh,    col, wid, Oemph);
  90.     drawvec(Ox,     Oyh,    Ox+hw2, Oy+hh7, col, wid, Oemph);
  91.     drawvec(Ox+hw2, Oy+hh7, Ox+hw7, Oy+hh2, col, wid, Oemph);
  92.     drawvec(Ox+hw7, Oy+hh2, Oxh,    Oy,     col, wid, Oemph);
  93.     drawvec(Oxh,    Oy,     Ox+hw7, Oy-hh2, col, wid, Oemph);
  94.     drawvec(Ox+hw7, Oy-hh2, Ox+hw2, Oy-hh7, col, wid, Oemph);
  95.     drawvec(Ox+hw2, Oy-hh7, Ox,     Oyl,    col, wid, Oemph);
  96.     drawvec(Ox,     Oyl,    Ox-hw2, Oy-hh7, col, wid, Oemph);
  97.     drawvec(Ox-hw2, Oy-hh7, Ox-hw7, Oy-hh2, col, wid, Oemph);
  98.     drawvec(Ox-hw7, Oy-hh2, Oxl,    Oy,     col, wid, Oemph);
  99.     }
  100.