Mercurial > hg > dmlib
annotate dmline.c @ 234:a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
functions to dmlib.h.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 08 Oct 2012 15:21:59 +0300 |
parents | 79dac918c81e |
children | 9d015d32841a |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Arbitrary line drawing functions | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
5 * (C) Copyright 2011 Tecnic Software productions (TNSP) | |
6 */ | |
7 #include "dmlib.h" | |
8 | |
9 /* Clip line coordinates. Return value: | |
10 * = 0 : No clipping needed. | |
11 * > 0 : Clipped. Line partially inside the clipping area. | |
12 * < 0 : Line completely outside the clipping area. | |
13 */ | |
133
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
14 #define dmClipBits(Q, x, y) \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
15 do { \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
16 Q = 0; \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
17 if (x < clipX0) Q |= 1; \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
18 else \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
19 if (x > clipX1) Q |= 2; \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
20 if (y < clipY0) Q |= 4; \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
21 else \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
22 if (y > clipY1) Q |= 8; \ |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
23 } while (0) |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
24 |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
25 #define xA (*x0) |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
26 #define xB (*x1) |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
27 #define yA (*y0) |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
28 #define yB (*y1) |
92cc5e1fa180
Some work on line drawing routines.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
29 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
30 #define DM_CLIP_FUNC dmClipLineCoordsInt |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
31 #define DM_COORD_TYPE int |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
32 #include "dmlineclip.h" |
0 | 33 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
34 #define DM_CLIP_FUNC dmClipLineCoordsFloat |
234
a2abd0b991b6
Modularize line drawing related templates and functions, add clipping
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
35 #define DM_COORD_TYPE DMFloat |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
36 #include "dmlineclip.h" |
0 | 37 |
38 | |
39 #include "dmlinefunc.h" |