2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #define SWAP(x, y) do { \
27 x ^= y; y ^= x; x ^= y; \
31 InsertLine (GArray *points, Point *src, Point *dst)
34 int inc, err, thre, swap;
37 rect.name = src->name;
46 if (ABS (inc) > ABS (thre))
53 for (y = y1, x = x1; (x2 < x1) ? (x >= x2) : (x <= x2); (x2 < x1) ? x-- : x++)
55 rect.x = (swap ? y : x);
56 rect.y = (swap ? x : y);
57 g_array_append_val (points, rect);
59 if (err >= ABS (thre))
62 y += (inc < 0) ? -1 : 1;
68 ReadPoints (char *filename)
79 file = fopen (filename, "r");
80 points = g_array_new (FALSE, TRUE, sizeof (SDL_Rect));
81 names = g_ptr_array_new ();
89 r = getline (&buffer, &len, file);
91 rect.x = strtol (buffer, &next, 0);
92 rect.y = strtol (next+1, &next, 0);
93 strtol (next, &next, 0);
95 InsertLine (points, &last, &rect);
96 while (isspace (*next)) next++;
97 rect.name = g_strdup (next);