diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-13 12:52:35 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-13 12:52:35 +0100 |
| commit | 8cdc05b1a227a2a1185eb6b33acb22e36e6a42f5 (patch) | |
| tree | b1e7e93ea4d1e3e6c96710523467096662a5ed1c /src/flcurve.cxx | |
| parent | dfa9e1677f24e06e8da8a136bc568c2f0be1d050 (diff) | |
parse -C argument in flcurve
Diffstat (limited to 'src/flcurve.cxx')
| -rw-r--r-- | src/flcurve.cxx | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/flcurve.cxx b/src/flcurve.cxx index 2769a51..ca0d901 100644 --- a/src/flcurve.cxx +++ b/src/flcurve.cxx @@ -17,6 +17,9 @@ #include "CurveEditor.H" +static void +parse_curve(CurveEditor *ce, const char *ctrl_points); + void usage() { fprintf(stderr, @@ -27,13 +30,17 @@ usage() { int main(int argc, char **argv) { int c, n, i, err; + char *curve = NULL; - while ((c = getopt(argc, argv, "?hs:g:d:f:i:")) != EOF) { + while ((c = getopt(argc, argv, "?hs:g:d:f:i:C:")) != EOF) { switch (c) { case '?': case 'h': usage(); exit(0); + case 'C': + curve = optarg; + break; default: i = optind - 1; n = Fl::arg(argc, argv, i); @@ -51,7 +58,34 @@ main(int argc, char **argv) { window.end(); window.resizable(ce); + if (curve) { + parse_curve(&ce, curve); + } + window.show(1, argv); return Fl::run(); } + +static void +parse_curve(CurveEditor *ce, const char *ctrl_points) { + char *pstr, *buf = strdup(ctrl_points); + int i, n = 0; + double X, Y; + gsl_interp_accel *acc; + gsl_spline *spline; + + while (pstr = strsep(&buf, ";")) { + if (sscanf(pstr, "%lf,%lf", &X, &Y) != 2 || + X < 0.0 || X > 1.0 || Y < 0.0 || Y > 1.0) { + fprintf(stderr, "Could not parse control point %s.\n", pstr); + continue; + } + + ce->add_point(X, Y); + } + + free(buf); + + ce->init(); +} |
