| 1 |
/* $XConsortium: t1snap.c,v 1.3 91/10/10 11:19:47 rws Exp $ */ |
| 2 |
/* Copyright International Business Machines,Corp. 1991 |
| 3 |
* All Rights Reserved |
| 4 |
* |
| 5 |
* License to use, copy, modify, and distribute this software |
| 6 |
* and its documentation for any purpose and without fee is |
| 7 |
* hereby granted, provided that the above copyright notice |
| 8 |
* appear in all copies and that both that copyright notice and |
| 9 |
* this permission notice appear in supporting documentation, |
| 10 |
* and that the name of IBM not be used in advertising or |
| 11 |
* publicity pertaining to distribution of the software without |
| 12 |
* specific, written prior permission. |
| 13 |
* |
| 14 |
* IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES |
| 15 |
* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT |
| 16 |
* LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF |
| 18 |
* THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND |
| 19 |
* PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT |
| 20 |
* OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF |
| 21 |
* THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES |
| 22 |
* THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN |
| 23 |
* NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 24 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
| 25 |
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 26 |
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 27 |
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 28 |
* SOFTWARE. |
| 29 |
*/ |
| 30 |
|
| 31 |
#include "types.h" |
| 32 |
#include "objects.h" |
| 33 |
#include "spaces.h" |
| 34 |
#include "paths.h" |
| 35 |
#include "pictures.h" |
| 36 |
|
| 37 |
/* |
| 38 |
:h2.Handle Functions |
| 39 |
|
| 40 |
:h3.Phantom() - Returns a Move Segment Equivalent to Handles |
| 41 |
|
| 42 |
This is a user operator. Its new name is QueryHandle. |
| 43 |
*/ |
| 44 |
|
| 45 |
struct segment *t1_Phantom( |
| 46 |
register struct segment *obj) /* object to take the Phantom of */ |
| 47 |
{ |
| 48 |
struct fractpoint pt; /* handle size will built here */ |
| 49 |
|
| 50 |
if (obj == NULL) |
| 51 |
pt.x = pt.y = 0; |
| 52 |
else |
| 53 |
PathDelta(obj, &pt); |
| 54 |
|
| 55 |
return(PathSegment(MOVETYPE, pt.x, pt.y)); |
| 56 |
} |
| 57 |
|
| 58 |
/* |
| 59 |
:h3.Snap() - Force Ending Handle of Object to Origin |
| 60 |
|
| 61 |
This is a user operator. |
| 62 |
*/ |
| 63 |
|
| 64 |
struct segment *t1_Snap( |
| 65 |
register struct segment *p) /* path to snap */ |
| 66 |
{ |
| 67 |
struct fractpoint pt; /* for finding length of path */ |
| 68 |
|
| 69 |
if (p == NULL) |
| 70 |
return(NULL); |
| 71 |
p = UniquePath(p); |
| 72 |
|
| 73 |
PathDelta(p, &pt); |
| 74 |
if (p->last->type == MOVETYPE) { |
| 75 |
p->last->dest.x -= pt.x; |
| 76 |
p->last->dest.y -= pt.y; |
| 77 |
} |
| 78 |
else |
| 79 |
p = JoinSegment(p, MOVETYPE, -pt.x, -pt.y, NULL); |
| 80 |
return(p); |
| 81 |
} |