1
1
/* edge.c: operations on edges in bitmaps.
3
Copyright (C) 1992 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2, or (at your option)
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
3
* Copyright (C) 1992 Free Software Foundation, Inc.
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2, or (at your option)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20
#include "config.h"
40
41
static edge_type next_edge (edge_type);
42
43
/* The following macros are used (directly or indirectly) by the
43
`next_outline_edge' routine. */
44
`next_outline_edge' routine. */
45
46
/* Given the direction DIR of the pixel to test, decide which edge on
46
47
that pixel we are supposed to test. Because we've chosen the mapping
53
54
`COL'). We are in the ``display'' coordinate system, with y
54
55
increasing downward and x increasing to the right. Therefore, we are
55
56
implementing the following table:
57
58
direction row delta col delta
63
64
with the other four directions (e.g., northwest) being the sum of
64
65
their components (e.g., north + west).
66
67
The first macro, `COMPUTE_DELTA', handles splitting up the latter
67
68
cases, all of which have been assigned odd numbers. */
69
70
#define COMPUTE_DELTA(axis, dir) \
71
72
? COMPUTE_##axis##_DELTA ((dir) - 1) \
109
110
on the current pixel. We want to go around outside outlines
110
111
counterclockwise, and inside outlines clockwise (because that is how
111
112
both Metafont and Adobe Type 1 format want their curves to be drawn).
113
114
The very first outline (an outside one) on each character starts on a
114
115
top edge (STARTING_EDGE in edge.h defines this); so, if we're at a
115
116
top edge, we want to go only to the left (on the pixel to the west)
116
117
or down (on the same pixel), to begin with. Then, when we're on a
117
118
left edge, we want to go to the top edge (on the southwest pixel) or
118
119
to the left edge (on the south pixel).
120
121
All well and good. But if you draw a rasterized circle (or whatever),
121
122
eventually we have to come back around to the beginning; at that
122
123
point, we'll be on a top edge, and we'll have to go to the right edge
123
124
on the northwest pixel. Draw pictures.
125
126
The upshot is, if we find an edge on another pixel, we return (in ROW
126
127
and COL) the position of the new pixel, and (in EDGE) the kind of
127
128
edge it is. If we don't find such an edge, we return (in EDGE) the
215
216
return row == 0 || sel_pixel_is_white(row - 1, col);
218
return (col == sel_get_width() - 1)
219
return (col == sel_get_width() - 1)
219
220
|| sel_pixel_is_white(row, col + 1);
222
return (row == sel_get_height() - 1)
223
return (row == sel_get_height() - 1)
223
224
|| sel_pixel_is_white(row + 1, col);
227
228
printf ("is_outline_edge: Bad edge value(%d)", edge);
230
231
return 0; /* NOTREACHED */