summaryrefslogtreecommitdiff
path: root/meme/overlay.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-15 21:51:46 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-15 21:51:46 (GMT)
commit1f33a9716932836c257295dd02f1f24abcb0eb4f (patch)
treeb1f52c8005ec5b73c36c72678be580511fe2bd1f /meme/overlay.c
parent57ff0b618c936a0f48d445f78beaeb6b7b000f59 (diff)
downloadmisc-1f33a9716932836c257295dd02f1f24abcb0eb4f.zip
misc-1f33a9716932836c257295dd02f1f24abcb0eb4f.tar.gz
misc-1f33a9716932836c257295dd02f1f24abcb0eb4f.tar.bz2
meme/: generalize overlay handling (let caller provide coordinate transform)
This will let us share the code with vispcb.
Diffstat (limited to 'meme/overlay.c')
-rw-r--r--meme/overlay.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/meme/overlay.c b/meme/overlay.c
index fd85de4..70bf4e2 100644
--- a/meme/overlay.c
+++ b/meme/overlay.c
@@ -13,7 +13,6 @@
#include <stdlib.h>
#include <stdio.h>
-#include <math.h>
#include "util.h"
#include "overlay.h"
@@ -46,7 +45,8 @@ void overlay_draw(const struct overlay *overlay,
}
-static struct overlay *overlay_load_file(FILE *file)
+static struct overlay *overlay_load_file(FILE *file,
+ void (*xform)(float x, float y, float *res_x, float *res_y))
{
struct overlay *over = NULL;
struct overlay *path = NULL;
@@ -81,8 +81,12 @@ static struct overlay *overlay_load_file(FILE *file)
over = path;
}
p = alloc_type(struct point);
- p->x = round(x * 1000);
- p->y = round(y * 1000);
+ if (xform) {
+ xform(x, y, &p->x, &p->y);
+ } else {
+ p->x = x;
+ p->y = y;
+ }
p->next = path->points;
path->points = p;
}
@@ -90,7 +94,8 @@ static struct overlay *overlay_load_file(FILE *file)
}
-struct overlay *overlay_load(const char *name)
+struct overlay *overlay_load(const char *name,
+ void (*xform)(float x, float y, float *res_x, float *res_y))
{
FILE *file;
struct overlay *over;
@@ -100,7 +105,7 @@ struct overlay *overlay_load(const char *name)
perror(name);
exit(1);
}
- over = overlay_load_file(file);
+ over = overlay_load_file(file, xform);
fclose(file);
return over;
}