Back to index

tetex-bin  3.0
t1snap.c
Go to the documentation of this file.
00001 /* $XConsortium: t1snap.c,v 1.3 91/10/10 11:19:47 rws Exp $ */
00002 /* Copyright International Business Machines,Corp. 1991
00003  * All Rights Reserved
00004  *
00005  * License to use, copy, modify, and distribute this software
00006  * and its documentation for any purpose and without fee is
00007  * hereby granted, provided that the above copyright notice
00008  * appear in all copies and that both that copyright notice and
00009  * this permission notice appear in supporting documentation,
00010  * and that the name of IBM not be used in advertising or
00011  * publicity pertaining to distribution of the software without
00012  * specific, written prior permission.
00013  *
00014  * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
00015  * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
00016  * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
00018  * THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE QUALITY AND
00019  * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF
00021  * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
00022  * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN
00023  * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00024  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
00025  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00026  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00027  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00028  * SOFTWARE.
00029  */
00030  
00031 #include "objects.h"
00032 #include "spaces.h"
00033 #include "paths.h"
00034  
00035 /*
00036 :h2.Handle Functions
00037  
00038 :h3.Phantom() - Returns a Move Segment Equivalent to Handles
00039  
00040 This is a user operator.  Its new name is QueryHandle.
00041 */
00042  
00043 struct segment *t1_Phantom(obj)
00044        register struct xobject *obj;  /* object to take the Phantom of       */
00045 {
00046        struct fractpoint pt; /* handle size will built here                  */
00047  
00048        if (obj == NULL)
00049                pt.x = pt.y = 0;
00050        else
00051                PathDelta(obj, &pt);
00052  
00053        return(PathSegment(MOVETYPE, pt.x, pt.y));
00054 }
00055  
00056 /*
00057 :h3.Snap() - Force Ending Handle of Object to Origin
00058  
00059 This is a user operator.
00060 */
00061  
00062 struct xobject *t1_Snap(p)
00063        register struct segment *p;  /* path to snap                          */
00064 {
00065        struct fractpoint pt; /* for finding length of path                   */
00066  
00067        if (p == NULL)
00068                return(NULL);
00069        p = UniquePath(p);
00070  
00071        PathDelta(p, &pt);
00072        if (p->last->type == MOVETYPE) {
00073                p->last->dest.x -= pt.x;
00074                p->last->dest.y -= pt.y;
00075        }
00076        else
00077                p = JoinSegment(p, MOVETYPE, -pt.x, -pt.y, NULL);
00078        return((struct xobject *)p);
00079 }