summaryrefslogtreecommitdiff
path: root/src/flcurve.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/flcurve.cxx')
-rw-r--r--src/flcurve.cxx36
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();
+}