diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-09-07 18:21:33 +0200 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-09-07 18:21:33 +0200 |
| commit | 4597762a61d5290094736e0d8761fa80dda13555 (patch) | |
| tree | 63acc65d6762d615745b66d7dacc0d4b5cd116f4 /src/pnmcurvedit.cxx | |
| parent | 4ce660903f966504c2828039e355118d4956af4d (diff) | |
use precision 4
Diffstat (limited to 'src/pnmcurvedit.cxx')
| -rw-r--r-- | src/pnmcurvedit.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/pnmcurvedit.cxx b/src/pnmcurvedit.cxx index 52a473d..3c12229 100644 --- a/src/pnmcurvedit.cxx +++ b/src/pnmcurvedit.cxx @@ -25,7 +25,7 @@ static void editor_cb(Fl_Widget* o, void* d) { if (i != 0) printf(","); ce->get_point(i, &x, &y); - printf("%g:%g", x, y); + printf("%.4f:%.4f", x, y); } printf("\n"); fflush(stdout); @@ -37,28 +37,26 @@ stdin_cb(int fd, void *d) { fgets(cmd, sizeof(cmd), stdin); - for (int i = strlen(cmd) - 1; i >= 0; i--) { + for (int i = strlen(cmd) - 1; i >= 0; i--) if (isspace(cmd[i])) { cmd[i] = '\0'; if (curve) break; - } else { + } else curve = &cmd[i]; - } - } if (curve) { - double X, Y; + double x, y; char *pstr; ce->clear(); while (pstr = strsep(&curve, ",")) { - if (sscanf(pstr, "%lf:%lf", &X, &Y) != 2 || - X < 0 || X > 1 || Y < 0 || Y > 1) { + if (sscanf(pstr, "%lf:%lf", &x, &y) != 2 || + y < 0 || x > 1 || y < 0 || y > 1) { fprintf(stderr, "Could not parse control point %s.\n", pstr); continue; } - ce->add_point(X, Y); + ce->add_point(x, y); } } } @@ -68,7 +66,7 @@ main(int argc, char **argv) { Fl_Double_Window window(800, 600, "pnmcurvedit"); ce = new CurveEditor(0, 0, 800, 600); ce->add_point(0.0, 0.0); - ce->add_point(0.5, 0.4); + ce->add_point(0.5, 0.5); ce->add_point(1.0, 1.0); ce->callback(editor_cb, NULL); |
