4
* This module provides procedures to draw borders in
5
* the three-dimensional Motif style.
7
* Copyright (c) 1990-1994 The Regents of the University of California.
8
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
10
* See the file "license.terms" for information on usage and redistribution
11
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
* RCS: @(#) $Id: tk3d.c,v 1.2 1998/09/14 18:23:02 stanton Exp $
19
* Hash table to map from a border's values (color, etc.) to a
20
* Border structure for those values.
23
static Tcl_HashTable borderTable;
25
Tk_Uid colorName; /* Color for border. */
26
Colormap colormap; /* Colormap used for allocating border
28
Screen *screen; /* Screen on which border will be drawn. */
31
static int initialized = 0; /* 0 means static structures haven't
32
* been initialized yet. */
35
* Forward declarations for procedures defined in this file:
38
static void BorderInit _ANSI_ARGS_((void));
39
static int Intersect _ANSI_ARGS_((XPoint *a1Ptr, XPoint *a2Ptr,
40
XPoint *b1Ptr, XPoint *b2Ptr, XPoint *iPtr));
41
static void ShiftLine _ANSI_ARGS_((XPoint *p1Ptr, XPoint *p2Ptr,
42
int distance, XPoint *p3Ptr));
45
*--------------------------------------------------------------
49
* Create a data structure for displaying a 3-D border.
52
* The return value is a token for a data structure
53
* describing a 3-D border. This token may be passed
54
* to Tk_Draw3DRectangle and Tk_Free3DBorder. If an
55
* error prevented the border from being created then
56
* NULL is returned and an error message will be left
60
* Data structures, graphics contexts, etc. are allocated.
61
* It is the caller's responsibility to eventually call
62
* Tk_Free3DBorder to release the resources.
64
*--------------------------------------------------------------
68
Tk_Get3DBorder(interp, tkwin, colorName)
69
Tcl_Interp *interp; /* Place to store an error message. */
70
Tk_Window tkwin; /* Token for window in which border will
72
Tk_Uid colorName; /* String giving name of color
73
* for window background. */
76
Tcl_HashEntry *hashPtr;
77
register TkBorder *borderPtr;
86
* First, check to see if there's already a border that will work
90
key.colorName = colorName;
91
key.colormap = Tk_Colormap(tkwin);
92
key.screen = Tk_Screen(tkwin);
94
hashPtr = Tcl_CreateHashEntry(&borderTable, (char *) &key, &new);
96
borderPtr = (TkBorder *) Tcl_GetHashValue(hashPtr);
97
borderPtr->refCount++;
102
* No satisfactory border exists yet. Initialize a new one.
105
bgColorPtr = Tk_GetColor(interp, tkwin, colorName);
106
if (bgColorPtr == NULL) {
107
Tcl_DeleteHashEntry(hashPtr);
111
borderPtr = TkpGetBorder();
112
borderPtr->screen = Tk_Screen(tkwin);
113
borderPtr->visual = Tk_Visual(tkwin);
114
borderPtr->depth = Tk_Depth(tkwin);
115
borderPtr->colormap = key.colormap;
116
borderPtr->refCount = 1;
117
borderPtr->bgColorPtr = bgColorPtr;
118
borderPtr->darkColorPtr = NULL;
119
borderPtr->lightColorPtr = NULL;
120
borderPtr->shadow = None;
121
borderPtr->bgGC = None;
122
borderPtr->darkGC = None;
123
borderPtr->lightGC = None;
124
borderPtr->hashPtr = hashPtr;
125
Tcl_SetHashValue(hashPtr, borderPtr);
128
* Create the information for displaying the background color,
129
* but delay the allocation of shadows until they are actually
130
* needed for drawing.
133
gcValues.foreground = borderPtr->bgColorPtr->pixel;
134
borderPtr->bgGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
136
return (Tk_3DBorder) borderPtr;
140
*--------------------------------------------------------------
142
* Tk_Draw3DRectangle --
144
* Draw a 3-D border at a given place in a given window.
150
* A 3-D border will be drawn in the indicated drawable.
151
* The outside edges of the border will be determined by x,
152
* y, width, and height. The inside edges of the border
153
* will be determined by the borderWidth argument.
155
*--------------------------------------------------------------
159
Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width, height,
161
Tk_Window tkwin; /* Window for which border was allocated. */
162
Drawable drawable; /* X window or pixmap in which to draw. */
163
Tk_3DBorder border; /* Token for border to draw. */
164
int x, y, width, height; /* Outside area of region in
165
* which border will be drawn. */
166
int borderWidth; /* Desired width for border, in
168
int relief; /* Type of relief: TK_RELIEF_RAISED,
169
* TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, etc. */
171
if (width < 2*borderWidth) {
172
borderWidth = width/2;
174
if (height < 2*borderWidth) {
175
borderWidth = height/2;
177
Tk_3DVerticalBevel(tkwin, drawable, border, x, y, borderWidth, height,
179
Tk_3DVerticalBevel(tkwin, drawable, border, x+width-borderWidth, y,
180
borderWidth, height, 0, relief);
181
Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, borderWidth,
183
Tk_3DHorizontalBevel(tkwin, drawable, border, x, y+height-borderWidth,
184
width, borderWidth, 0, 0, 0, relief);
188
*--------------------------------------------------------------
190
* Tk_NameOf3DBorder --
192
* Given a border, return a textual string identifying the
196
* The return value is the string that was used to create
202
*--------------------------------------------------------------
206
Tk_NameOf3DBorder(border)
207
Tk_3DBorder border; /* Token for border. */
209
TkBorder *borderPtr = (TkBorder *) border;
211
return ((BorderKey *) borderPtr->hashPtr->key.words)->colorName;
215
*--------------------------------------------------------------------
217
* Tk_3DBorderColor --
219
* Given a 3D border, return the X color used for the "flat"
223
* Returns the color used drawing flat surfaces with the border.
228
*--------------------------------------------------------------------
231
Tk_3DBorderColor(border)
232
Tk_3DBorder border; /* Border whose color is wanted. */
234
return(((TkBorder *) border)->bgColorPtr);
238
*--------------------------------------------------------------------
242
* Given a 3D border, returns one of the graphics contexts used to
246
* Returns the graphics context given by the "which" argument.
251
*--------------------------------------------------------------------
254
Tk_3DBorderGC(tkwin, border, which)
255
Tk_Window tkwin; /* Window for which border was allocated. */
256
Tk_3DBorder border; /* Border whose GC is wanted. */
257
int which; /* Selects one of the border's 3 GC's:
258
* TK_3D_FLAT_GC, TK_3D_LIGHT_GC, or
261
TkBorder * borderPtr = (TkBorder *) border;
263
if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) {
264
TkpGetShadows(borderPtr, tkwin);
266
if (which == TK_3D_FLAT_GC) {
267
return borderPtr->bgGC;
268
} else if (which == TK_3D_LIGHT_GC) {
269
return borderPtr->lightGC;
270
} else if (which == TK_3D_DARK_GC){
271
return borderPtr->darkGC;
273
panic("bogus \"which\" value in Tk_3DBorderGC");
276
* The code below will never be executed, but it's needed to
277
* keep compilers happy.
284
*--------------------------------------------------------------
288
* This procedure is called when a 3D border is no longer
289
* needed. It frees the resources associated with the
290
* border. After this call, the caller should never again
291
* use the "border" token.
297
* Resources are freed.
299
*--------------------------------------------------------------
303
Tk_Free3DBorder(border)
304
Tk_3DBorder border; /* Token for border to be released. */
306
register TkBorder *borderPtr = (TkBorder *) border;
307
Display *display = DisplayOfScreen(borderPtr->screen);
309
borderPtr->refCount--;
310
if (borderPtr->refCount == 0) {
311
TkpFreeBorder(borderPtr);
312
if (borderPtr->bgColorPtr != NULL) {
313
Tk_FreeColor(borderPtr->bgColorPtr);
315
if (borderPtr->darkColorPtr != NULL) {
316
Tk_FreeColor(borderPtr->darkColorPtr);
318
if (borderPtr->lightColorPtr != NULL) {
319
Tk_FreeColor(borderPtr->lightColorPtr);
321
if (borderPtr->shadow != None) {
322
Tk_FreeBitmap(display, borderPtr->shadow);
324
if (borderPtr->bgGC != None) {
325
Tk_FreeGC(display, borderPtr->bgGC);
327
if (borderPtr->darkGC != None) {
328
Tk_FreeGC(display, borderPtr->darkGC);
330
if (borderPtr->lightGC != None) {
331
Tk_FreeGC(display, borderPtr->lightGC);
333
Tcl_DeleteHashEntry(borderPtr->hashPtr);
334
ckfree((char *) borderPtr);
339
*----------------------------------------------------------------------
341
* Tk_SetBackgroundFromBorder --
343
* Change the background of a window to one appropriate for a given
350
* Tkwin's background gets modified.
352
*----------------------------------------------------------------------
356
Tk_SetBackgroundFromBorder(tkwin, border)
357
Tk_Window tkwin; /* Window whose background is to be set. */
358
Tk_3DBorder border; /* Token for border. */
360
register TkBorder *borderPtr = (TkBorder *) border;
362
Tk_SetWindowBackground(tkwin, borderPtr->bgColorPtr->pixel);
366
*----------------------------------------------------------------------
370
* Parse a relief description and return the corresponding
371
* relief value, or an error.
374
* A standard Tcl return value. If all goes well then
375
* *reliefPtr is filled in with one of the values
376
* TK_RELIEF_RAISED, TK_RELIEF_FLAT, or TK_RELIEF_SUNKEN.
381
*----------------------------------------------------------------------
385
Tk_GetRelief(interp, name, reliefPtr)
386
Tcl_Interp *interp; /* For error messages. */
387
char *name; /* Name of a relief type. */
388
int *reliefPtr; /* Where to store converted relief. */
394
length = strlen(name);
395
if ((c == 'f') && (strncmp(name, "flat", length) == 0)) {
396
*reliefPtr = TK_RELIEF_FLAT;
397
} else if ((c == 'g') && (strncmp(name, "groove", length) == 0)
399
*reliefPtr = TK_RELIEF_GROOVE;
400
} else if ((c == 'r') && (strncmp(name, "raised", length) == 0)
402
*reliefPtr = TK_RELIEF_RAISED;
403
} else if ((c == 'r') && (strncmp(name, "ridge", length) == 0)) {
404
*reliefPtr = TK_RELIEF_RIDGE;
405
} else if ((c == 's') && (strncmp(name, "solid", length) == 0)) {
406
*reliefPtr = TK_RELIEF_SOLID;
407
} else if ((c == 's') && (strncmp(name, "sunken", length) == 0)) {
408
*reliefPtr = TK_RELIEF_SUNKEN;
410
sprintf(interp->result, "bad relief type \"%.50s\": must be %s",
411
name, "flat, groove, raised, ridge, solid, or sunken");
418
*--------------------------------------------------------------
422
* Given a relief value, produce a string describing that
426
* The return value is a static string that is equivalent
432
*--------------------------------------------------------------
436
Tk_NameOfRelief(relief)
437
int relief; /* One of TK_RELIEF_FLAT, TK_RELIEF_RAISED,
438
* or TK_RELIEF_SUNKEN. */
440
if (relief == TK_RELIEF_FLAT) {
442
} else if (relief == TK_RELIEF_SUNKEN) {
444
} else if (relief == TK_RELIEF_RAISED) {
446
} else if (relief == TK_RELIEF_GROOVE) {
448
} else if (relief == TK_RELIEF_RIDGE) {
450
} else if (relief == TK_RELIEF_SOLID) {
453
return "unknown relief";
458
*--------------------------------------------------------------
460
* Tk_Draw3DPolygon --
462
* Draw a border with 3-D appearance around the edge of a
469
* Information is drawn in "drawable" in the form of a
470
* 3-D border borderWidth units width wide on the left
471
* of the trajectory given by pointPtr and numPoints (or
472
* -borderWidth units wide on the right side, if borderWidth
475
*--------------------------------------------------------------
479
Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
480
borderWidth, leftRelief)
481
Tk_Window tkwin; /* Window for which border was allocated. */
482
Drawable drawable; /* X window or pixmap in which to draw. */
483
Tk_3DBorder border; /* Token for border to draw. */
484
XPoint *pointPtr; /* Array of points describing
485
* polygon. All points must be
486
* absolute (CoordModeOrigin). */
487
int numPoints; /* Number of points at *pointPtr. */
488
int borderWidth; /* Width of border, measured in
489
* pixels to the left of the polygon's
490
* trajectory. May be negative. */
491
int leftRelief; /* TK_RELIEF_RAISED or
492
* TK_RELIEF_SUNKEN: indicates how
493
* stuff to left of trajectory looks
494
* relative to stuff on right. */
496
XPoint poly[4], b1, b2, newB1, newB2;
497
XPoint perp, c, shift1, shift2; /* Used for handling parallel lines. */
498
register XPoint *p1Ptr, *p2Ptr;
499
TkBorder *borderPtr = (TkBorder *) border;
501
int i, lightOnLeft, dx, dy, parallel, pointsSeen;
502
Display *display = Tk_Display(tkwin);
504
if (borderPtr->lightGC == None) {
505
TkpGetShadows(borderPtr, tkwin);
509
* Handle grooves and ridges with recursive calls.
512
if ((leftRelief == TK_RELIEF_GROOVE) || (leftRelief == TK_RELIEF_RIDGE)) {
515
halfWidth = borderWidth/2;
516
Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
517
halfWidth, (leftRelief == TK_RELIEF_GROOVE) ? TK_RELIEF_RAISED
519
Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
520
-halfWidth, (leftRelief == TK_RELIEF_GROOVE) ? TK_RELIEF_SUNKEN
526
* If the polygon is already closed, drop the last point from it
527
* (we'll close it automatically).
530
p1Ptr = &pointPtr[numPoints-1];
531
p2Ptr = &pointPtr[0];
532
if ((p1Ptr->x == p2Ptr->x) && (p1Ptr->y == p2Ptr->y)) {
537
* The loop below is executed once for each vertex in the polgon.
538
* At the beginning of each iteration things look like this:
543
* b1 * poly[0] (pointPtr[i-1])
550
* b2 *--------------------*
553
* x-------------------------
555
* The job of this iteration is to do the following:
556
* (a) Compute x (the border corner corresponding to
557
* pointPtr[i]) and put it in poly[2]. As part of
558
* this, compute a new b1 and b2 value for the next
559
* side of the polygon.
560
* (b) Put pointPtr[i] into poly[3].
561
* (c) Draw the polygon given by poly[0..3].
562
* (d) Advance poly[0], poly[1], b1, and b2 for the
563
* next side of the polygon.
567
* The above situation doesn't first come into existence until
568
* two points have been processed; the first two points are
569
* used to "prime the pump", so some parts of the processing
570
* are ommitted for these points. The variable "pointsSeen"
571
* keeps track of the priming process; it has to be separate
572
* from i in order to be able to ignore duplicate points in the
577
for (i = -2, p1Ptr = &pointPtr[numPoints-2], p2Ptr = p1Ptr+1;
578
i < numPoints; i++, p1Ptr = p2Ptr, p2Ptr++) {
579
if ((i == -1) || (i == numPoints-1)) {
582
if ((p2Ptr->x == p1Ptr->x) && (p2Ptr->y == p1Ptr->y)) {
584
* Ignore duplicate points (they'd cause core dumps in
585
* ShiftLine calls below).
589
ShiftLine(p1Ptr, p2Ptr, borderWidth, &newB1);
590
newB2.x = newB1.x + (p2Ptr->x - p1Ptr->x);
591
newB2.y = newB1.y + (p2Ptr->y - p1Ptr->y);
594
if (pointsSeen >= 1) {
595
parallel = Intersect(&newB1, &newB2, &b1, &b2, &poly[2]);
598
* If two consecutive segments of the polygon are parallel,
599
* then things get more complex. Consider the following
603
* *----b1-----------b2------a
606
* *---------*----------* b
607
* poly[0] *p2Ptr *p1Ptr /
612
* Instead of using x and *p1Ptr for poly[2] and poly[3], as
613
* in the original diagram, use a and b as above. Then instead
614
* of using x and *p1Ptr for the new poly[0] and poly[1], use
617
* Do the computation in three stages:
618
* 1. Compute a point "perp" such that the line p1Ptr-perp
619
* is perpendicular to p1Ptr-p2Ptr.
620
* 2. Compute the points a and c by intersecting the lines
621
* b1-b2 and newB1-newB2 with p1Ptr-perp.
622
* 3. Compute b by shifting p1Ptr-perp to the right and
623
* intersecting it with p1Ptr-p2Ptr.
627
perp.x = p1Ptr->x + (p2Ptr->y - p1Ptr->y);
628
perp.y = p1Ptr->y - (p2Ptr->x - p1Ptr->x);
629
(void) Intersect(p1Ptr, &perp, &b1, &b2, &poly[2]);
630
(void) Intersect(p1Ptr, &perp, &newB1, &newB2, &c);
631
ShiftLine(p1Ptr, &perp, borderWidth, &shift1);
632
shift2.x = shift1.x + (perp.x - p1Ptr->x);
633
shift2.y = shift1.y + (perp.y - p1Ptr->y);
634
(void) Intersect(p1Ptr, p2Ptr, &shift1, &shift2, &poly[3]);
637
if (pointsSeen >= 2) {
638
dx = poly[3].x - poly[0].x;
639
dy = poly[3].y - poly[0].y;
641
lightOnLeft = (dy <= dx);
643
lightOnLeft = (dy < dx);
645
if (lightOnLeft ^ (leftRelief == TK_RELIEF_RAISED)) {
646
gc = borderPtr->lightGC;
648
gc = borderPtr->darkGC;
650
XFillPolygon(display, drawable, gc, poly, 4, Convex,
657
poly[0].x = poly[3].x;
658
poly[0].y = poly[3].y;
662
} else if (pointsSeen >= 1) {
663
poly[1].x = poly[2].x;
664
poly[1].y = poly[2].y;
671
*----------------------------------------------------------------------
673
* Tk_Fill3DRectangle --
675
* Fill a rectangular area, supplying a 3D border if desired.
681
* Information gets drawn on the screen.
683
*----------------------------------------------------------------------
687
Tk_Fill3DRectangle(tkwin, drawable, border, x, y, width,
688
height, borderWidth, relief)
689
Tk_Window tkwin; /* Window for which border was allocated. */
690
Drawable drawable; /* X window or pixmap in which to draw. */
691
Tk_3DBorder border; /* Token for border to draw. */
692
int x, y, width, height; /* Outside area of rectangular region. */
693
int borderWidth; /* Desired width for border, in
694
* pixels. Border will be *inside* region. */
695
int relief; /* Indicates 3D effect: TK_RELIEF_FLAT,
696
* TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */
698
register TkBorder *borderPtr = (TkBorder *) border;
702
* This code is slightly tricky because it only draws the background
703
* in areas not covered by the 3D border. This avoids flashing
704
* effects on the screen for the border region.
707
if (relief == TK_RELIEF_FLAT) {
710
doubleBorder = 2*borderWidth;
712
if ((width > doubleBorder) && (height > doubleBorder)) {
713
XFillRectangle(Tk_Display(tkwin), drawable, borderPtr->bgGC,
714
x + borderWidth, y + borderWidth,
715
(unsigned int) (width - doubleBorder),
716
(unsigned int) (height - doubleBorder));
719
Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width,
720
height, borderWidth, relief);
725
*----------------------------------------------------------------------
727
* Tk_Fill3DPolygon --
729
* Fill a polygonal area, supplying a 3D border if desired.
735
* Information gets drawn on the screen.
737
*----------------------------------------------------------------------
741
Tk_Fill3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
742
borderWidth, leftRelief)
743
Tk_Window tkwin; /* Window for which border was allocated. */
744
Drawable drawable; /* X window or pixmap in which to draw. */
745
Tk_3DBorder border; /* Token for border to draw. */
746
XPoint *pointPtr; /* Array of points describing
747
* polygon. All points must be
748
* absolute (CoordModeOrigin). */
749
int numPoints; /* Number of points at *pointPtr. */
750
int borderWidth; /* Width of border, measured in
751
* pixels to the left of the polygon's
752
* trajectory. May be negative. */
753
int leftRelief; /* Indicates 3D effect of left side of
754
* trajectory relative to right:
755
* TK_RELIEF_FLAT, TK_RELIEF_RAISED,
756
* or TK_RELIEF_SUNKEN. */
758
register TkBorder *borderPtr = (TkBorder *) border;
760
XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
761
pointPtr, numPoints, Complex, CoordModeOrigin);
762
if (leftRelief != TK_RELIEF_FLAT) {
763
Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
764
borderWidth, leftRelief);
769
*--------------------------------------------------------------
773
* Initialize the structures used for border management.
781
*-------------------------------------------------------------
788
Tcl_InitHashTable(&borderTable, sizeof(BorderKey)/sizeof(int));
792
*--------------------------------------------------------------
796
* Given two points on a line, compute a point on a
797
* new line that is parallel to the given line and
798
* a given distance away from it.
806
*--------------------------------------------------------------
810
ShiftLine(p1Ptr, p2Ptr, distance, p3Ptr)
811
XPoint *p1Ptr; /* First point on line. */
812
XPoint *p2Ptr; /* Second point on line. */
813
int distance; /* New line is to be this many
814
* units to the left of original
815
* line, when looking from p1 to
816
* p2. May be negative. */
817
XPoint *p3Ptr; /* Store coords of point on new
820
int dx, dy, dxNeg, dyNeg;
823
* The table below is used for a quick approximation in
824
* computing the new point. An index into the table
825
* is 128 times the slope of the original line (the slope
826
* must always be between 0 and 1). The value of the table
827
* entry is 128 times the amount to displace the new line
828
* in y for each unit of perpendicular distance. In other
829
* words, the table maps from the tangent of an angle to
830
* the inverse of its cosine. If the slope of the original
831
* line is greater than 1, then the displacement is done in
832
* x rather than in y.
835
static int shiftTable[129];
838
* Initialize the table if this is the first time it is
842
if (shiftTable[0] == 0) {
844
double tangent, cosine;
846
for (i = 0; i <= 128; i++) {
848
cosine = 128/cos(atan(tangent)) + .5;
849
shiftTable[i] = (int) cosine;
854
dx = p2Ptr->x - p1Ptr->x;
855
dy = p2Ptr->y - p1Ptr->y;
869
dy = ((distance * shiftTable[(dy<<7)/dx]) + 64) >> 7;
875
dx = ((distance * shiftTable[(dx<<7)/dy]) + 64) >> 7;
884
*--------------------------------------------------------------
888
* Find the intersection point between two lines.
891
* Under normal conditions 0 is returned and the point
892
* at *iPtr is filled in with the intersection between
893
* the two lines. If the two lines are parallel, then
894
* -1 is returned and *iPtr isn't modified.
899
*--------------------------------------------------------------
903
Intersect(a1Ptr, a2Ptr, b1Ptr, b2Ptr, iPtr)
904
XPoint *a1Ptr; /* First point of first line. */
905
XPoint *a2Ptr; /* Second point of first line. */
906
XPoint *b1Ptr; /* First point of second line. */
907
XPoint *b2Ptr; /* Second point of second line. */
908
XPoint *iPtr; /* Filled in with intersection point. */
910
int dxadyb, dxbdya, dxadxb, dyadyb, p, q;
913
* The code below is just a straightforward manipulation of two
914
* equations of the form y = (x-x1)*(y2-y1)/(x2-x1) + y1 to solve
915
* for the x-coordinate of intersection, then the y-coordinate.
918
dxadyb = (a2Ptr->x - a1Ptr->x)*(b2Ptr->y - b1Ptr->y);
919
dxbdya = (b2Ptr->x - b1Ptr->x)*(a2Ptr->y - a1Ptr->y);
920
dxadxb = (a2Ptr->x - a1Ptr->x)*(b2Ptr->x - b1Ptr->x);
921
dyadyb = (a2Ptr->y - a1Ptr->y)*(b2Ptr->y - b1Ptr->y);
923
if (dxadyb == dxbdya) {
926
p = (a1Ptr->x*dxbdya - b1Ptr->x*dxadyb + (b1Ptr->y - a1Ptr->y)*dxadxb);
933
iPtr->x = - ((-p + q/2)/q);
935
iPtr->x = (p + q/2)/q;
937
p = (a1Ptr->y*dxadyb - b1Ptr->y*dxbdya + (b1Ptr->x - a1Ptr->x)*dyadyb);
944
iPtr->y = - ((-p + q/2)/q);
946
iPtr->y = (p + q/2)/q;