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.
27 #define SWAP(x, y) do { \
28 x ^= y; y ^= x; x ^= y; \
32 InsertLine (GArray *points, Point *src, Point *dst)
35 int inc, err, thre, swap;
47 if (ABS (inc) > ABS (thre))
54 for (y = y1, x = x1; (x2 < x1) ? (x >= x2) : (x <= x2); (x2 < x1) ? x-- : x++)
56 rect.x = (swap ? y : x);
57 rect.y = (swap ? x : y);
58 g_array_append_val (points, rect);
60 if (err >= ABS (thre))
63 y += (inc < 0) ? -1 : 1;
69 ReadPoints (char *filename)
80 file = fopen (filename, "r");
81 points = g_array_new (FALSE, TRUE, sizeof (Point));
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);
94 while (isspace (*next)) next++;
95 rect.name = g_strdup (next);
97 InsertLine (points, &last, &rect);
98 g_array_append_val (points, rect);
107 rescale_points (GArray *points)
111 for (i = 0; i < points->len; i++)
113 point = &(g_array_index (points, Point, i));
116 point->x *= point->rx;
117 point->y *= point->ry;