home *** CD-ROM | disk | FTP | other *** search
- /*
- * lemobjsup.c - superclass for generic object operations
- *
- * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
- */
-
- #include <math.h> /* to define "double floor()" */
- #include "lem.h"
-
- objsupnearpt(i, x, y)
- {
- if (ptinrect(x, y, Oxl, Oyl, Oxh, Oyh, LINETOL) == 0) return(0);
- return(1);
- }
-
- objsupinrect(i, xl, yl, xh, yh)
- {
- return(ptinrect(Oxl, Oyl, xl, yl, xh, yh, LINETOL) &&
- ptinrect(Oxh, Oyh, xl, yl, xh, yh, LINETOL));
- }
-
- objsupcantug(i, x, y)
- {
- return(objnearpt(i, x, y));
- }
-
- objsuptug(i, xs, ys, xe, ye)
- {
- if (dist(Oxs, Oys, xs, ys) < TUGPROX) objmove(i, xe-xs, ye-ys);
- }
-
- objsupalign(i, x, y)
- int *x, *y;
- {
- if (dist(Oxs, Oys, *x, *y) < ENDTOL)
- {
- *x = Oxs;
- *y = Oys;
- }
- }
-
- objsupmove(i, x, y)
- {
- Oxs += x;
- Oxe += x;
- Oys += y;
- Oye += y;
- }
-
- objsupaffine(i, m11, m12, m21, m22, both)
- float m11, m12, m21, m22;
- {
- float x1, y1;
- if (both)
- {
- x1 = floor((m11*Oxs + m12*Oys) + 0.5);
- y1 = floor((m21*Oxs + m22*Oys) + 0.5);
- Oxs = x1;
- Oys = y1;
- x1 = floor((m11*Oxe + m12*Oye) + 0.5);
- y1 = floor((m21*Oxe + m22*Oye) + 0.5);
- Oxe = x1;
- Oye = y1;
- }
- else
- {
- x1 = floor((m11*Oxcen + m12*Oycen) + 0.5);
- y1 = floor((m21*Oxcen + m22*Oycen) + 0.5);
- /*
- * move only the center point, don't the other endpoint
- * (presumably object dimensions -- this is a text element).
- */
- objmove(i, (int)(x1-Oxcen), (int)(y1-Oycen));
- }
- }
-