annotate dmlineclip.h @ 264:200329bb7688

Fix the Cohen-Sutherland clipping implementation and add optional compile-time debugging.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Oct 2012 13:02:35 +0300
parents 9d015d32841a
children 51ba74f7668c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
1 /* Clip line coordinates. Return value:
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
2 * = 0 : No clipping needed.
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
3 * > 0 : Clipped. Line partially inside the clipping area.
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
4 * < 0 : Line completely outside the clipping area.
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
5 */
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
6
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
7 #ifndef DM_HEADER
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
8 #define DM_CLIP_BITS(QB, QX, QY) \
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
9 do { \
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
10 QB = 0; \
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
11 if (QX < clipX0) QB |= CLIP_LEFT; \
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
12 else \
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
13 if (QX > clipX1) QB |= CLIP_RIGHT; \
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
14 \
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
15 if (QY < clipY0) QB |= CLIP_TOP; \
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
16 else \
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
17 if (QY > clipY1) QB |= CLIP_BOTTOM; \
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
18 } while (0)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
19
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
20 #define xA (*x0)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
21 #define xB (*x1)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
22 #define yA (*y0)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
23 #define yB (*y1)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
24 #endif
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
25
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
26 #ifdef DM_CLIP_DEBUG
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
27 #define CLIPDEB(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
28 #else
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
29 #define CLIPDEB(fmt, ...)
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
30 #endif
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31
234
a2abd0b991b6 Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
32 int DM_CLIP_FUNC (SDL_Surface *screen, DM_COORD_TYPE *x0, DM_COORD_TYPE *y0, DM_COORD_TYPE *x1, DM_COORD_TYPE *y1)
a2abd0b991b6 Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
33 #ifdef DM_HEADER
a2abd0b991b6 Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
34 ;
a2abd0b991b6 Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
35 #else
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 const DM_COORD_TYPE
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 clipX0 = screen->clip_rect.x,
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 clipY0 = screen->clip_rect.y,
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 clipX1 = clipX0 + screen->clip_rect.w - 1,
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 clipY1 = clipY0 + screen->clip_rect.h - 1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
43 int clipA, clipB;
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
45 DM_CLIP_BITS(clipA, xA, yA);
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
46 DM_CLIP_BITS(clipB, xB, yB);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
48 CLIPDEB("-- clip [%d, %d - %d, %d] --\n", xA, yA, xB, yB);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
49
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
50 #if 1
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
51 // The segment is inside?
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
52 if ((clipA | clipB) == 0)
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
53 return 0;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
54
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
55 // The line segment is outside of the clip region
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
56 if (clipA & clipB)
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
57 return -1;
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 // Cohen-Sutherland clipping method
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 do
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 {
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
62 const int c = clipA ? clipA : clipB;
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 DM_COORD_TYPE x, y;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
65 #ifdef DM_CLIP_DEBUG
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
66 CLIPDEB "CLIP : ");
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
67 if (c == clipA)
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
68 CLIPDEB("A [%d, %d]\n", xA, yA);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
69 else
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
70 CLIPDEB("B [%d, %d]\n", xB, yB);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
71 #endif
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
72 if (c & CLIP_TOP)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 {
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
74 x = xA + ((clipY0 - yA) * (xB - xA)) / (yB - yA);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
75 y = clipY0;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
76 CLIPDEB("TOP : %d, %d\n", x, y);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 else
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
79 if (c & CLIP_BOTTOM)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 {
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
81 x = xA + ((clipY1 - yA) * (xB - xA)) / (yB - yA);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
82 y = clipY1;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
83 CLIPDEB("BOTTOM : %d, %d\n", x, y);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 else
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
86 if (c & CLIP_RIGHT)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 {
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
88 y = yA + ((clipX1 - xA) * (yB - yA)) / (xB - xA);
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
89 x = clipX1;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
90 CLIPDEB("RIGHT : %d, %d\n", x, y);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 {
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
94 y = yA + ((clipX0 - xA) * (yB - yA)) / xB - xA;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
95 x = clipX0;
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
96 CLIPDEB("LEFT : %d, %d\n", x, y);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
99 if (c == clipA)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 xA = x;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 yA = y;
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
103 DM_CLIP_BITS(clipA, xA, yA);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 xB = x;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 yB = y;
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
109 DM_CLIP_BITS(clipB, xB, yB);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
112 } while (clipA | clipB);
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 #else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 // Buyu-Skala clipping method
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 const DM_COORD_TYPE dx = xB - xA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 const DM_COORD_TYPE dy = yB - yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 float k, m;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 int z;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
120 switch (clipA + clipB)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 case 1:
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
123 if (clipA == 1)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 yA = (clipX0 - xB) * dy / dx + yB;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 xB = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 yB = (clipX0 - xA) * dy / dx + yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 case 3:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 k = dy / dx;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 yA = (clipX0 - xA) * k + yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 yB = (clipX1 - xB) * k + yB;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 xB = clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 case 5:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 k = dy / dx;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 z = (clipX0 - xA) * k + yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 if (z < clipY0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 {
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
148 switch (clipA)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 case 0:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 xB = xB + (clipY0 - yB) / k;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 yB = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 case 5:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 xA = xA + (clipY0 - yA) / k;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 yA = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 default:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 {
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
165 switch (clipA)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 case 0:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 xB = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 yB = z;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 case 1:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 xB = xB + (clipY0 - yB) / k;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 yB = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 yA = z;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 case 4:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 xA = xA + (clipY0 - yA) / k;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 yA = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 xB = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 yB = z;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 case 5:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 yA = z;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 case 7:
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
192 switch (clipA)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 case 1:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 k = dy / dx;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 yA = (clipX0 - xB) * k + yB;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 if (yA < clipY0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 yB = (clipX1 - clipX0) * k + yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 if (yB < clipY0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 xB = (clipY0 - yB) / k + clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 yB = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 xB = clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 break;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
210 /* similarly for cases clipA == 2, 5, 6 */
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 case 15:
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
213 switch (clipA)
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 case 5:
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 if (dy * (clipX1 - clipX0) < dx * (clipY1 - clipY0))
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 k = dy / dx;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 yA = (clipX0 - xB) * k + yB;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 if (yA > clipY1)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 yB = (clipX1 - clipX0) * k + yA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 if (yB < clipY0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 if (yA < clipY0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 xA = (clipY0 - yA) / k + clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 yA = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 xB = clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 if (yB > clipY1)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 xB = (clipY1 - yB) / k + clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 yB = clipY1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 xB = clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 m = dx / dy;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 xA = (clipY0 - yB) * m + xB;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 if (xA > clipX1)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 xB = (clipY1 - clipY0) * m + xA;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 if (xB < clipX0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 return -1; /* the line segment is outside */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 if (xA < clipX0)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 yA = (clipX0 - xA) / m + clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 xA = clipX0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 yB = clipY1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 yA = clipY0;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 if (xB > clipX1)
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 {
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 yB = (clipX1 - xB) / m + clipY1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 xB = clipX1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 else
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 yB = clipY1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
271 /* similarly for cases clipA == 6, 9, 10 */
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 }
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 /* cases 2, 4, 8 are similar as case 1, cases 6, 9, 10 are similar as case 5 */
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 /* cases 11, 13, 14 are similar as case 7, case 12 is similar case 3 */
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
276 } /* of case clipA + clipB */
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 #endif
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 return 1;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 }
262
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
281
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
282 #undef DM_CLIP_BITS
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
283 #undef xA
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
284 #undef xB
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
285 #undef yA
9d015d32841a Clean up the line clipping a bit, in preparation for fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 234
diff changeset
286 #undef yB
264
200329bb7688 Fix the Cohen-Sutherland clipping implementation and add optional
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
287 #undef CLIPDEB
234
a2abd0b991b6 Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
288 #endif
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 #undef DM_CLIP_FUNC
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 #undef DM_COORD_TYPE