summaryrefslogtreecommitdiff
path: root/meme/overlay.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-16 15:44:34 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-16 15:44:34 (GMT)
commit7a36d4f5b214d62268a085dad665b09c41f2b3c7 (patch)
tree9a5934c45ccae9d15cc346a10061ad04001953ef /meme/overlay.c
parent542ea751bc0d739ac4ff8490abd66726dd7c08ee (diff)
downloadmisc-7a36d4f5b214d62268a085dad665b09c41f2b3c7.zip
misc-7a36d4f5b214d62268a085dad665b09c41f2b3c7.tar.gz
misc-7a36d4f5b214d62268a085dad665b09c41f2b3c7.tar.bz2
meme/, vispcb/: separate paths from "struct overlay"
Diffstat (limited to 'meme/overlay.c')
-rw-r--r--meme/overlay.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/meme/overlay.c b/meme/overlay.c
index 70bf4e2..24c006f 100644
--- a/meme/overlay.c
+++ b/meme/overlay.c
@@ -23,9 +23,9 @@ struct point {
struct point *next;
};
-struct overlay {
+struct path {
struct point *points;
- struct overlay *next;
+ struct path *next;
};
@@ -33,10 +33,10 @@ void overlay_draw(const struct overlay *overlay,
void (*moveto)(void *user, int x, int y),
void (*lineto)(void *user, int x, int y), void *user)
{
- const struct overlay *path;
+ const struct path *path;
const struct point *p;
- for (path = overlay; path; path = path->next) {
+ for (path = overlay->paths; path; path = path->next) {
p = path->points;
moveto(user, p->x, p->y);
for (p = p->next; p; p = p->next)
@@ -45,17 +45,17 @@ void overlay_draw(const struct overlay *overlay,
}
-static struct overlay *overlay_load_file(FILE *file,
+static void overlay_load_file(struct overlay *overlay, FILE *file,
void (*xform)(float x, float y, float *res_x, float *res_y))
{
- struct overlay *over = NULL;
- struct overlay *path = NULL;
+ struct path *path = NULL;
struct point *p;
int lineno = 0;
char buf[1024];
int n;
double x, y, z;
+ overlay->paths = NULL;
while (fgets(buf, sizeof(buf), file)) {
lineno++;
if (*buf == '#')
@@ -75,10 +75,10 @@ static struct overlay *overlay_load_file(FILE *file,
}
if (!path) {
- path = alloc_type(struct overlay);
- path->next = over;
+ path = alloc_type(struct path);
+ path->next = overlay->paths;
path->points = NULL;
- over = path;
+ overlay->paths = path;
}
p = alloc_type(struct point);
if (xform) {
@@ -90,22 +90,19 @@ static struct overlay *overlay_load_file(FILE *file,
p->next = path->points;
path->points = p;
}
- return over;
}
-struct overlay *overlay_load(const char *name,
+void overlay_load(struct overlay *overlay, const char *name,
void (*xform)(float x, float y, float *res_x, float *res_y))
{
FILE *file;
- struct overlay *over;
file = fopen(name, "r");
if (!file) {
perror(name);
exit(1);
}
- over = overlay_load_file(file, xform);
+ overlay_load_file(overlay, file, xform);
fclose(file);
- return over;
}