summaryrefslogtreecommitdiff
path: root/src/CurveEditor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/CurveEditor.cxx')
-rw-r--r--src/CurveEditor.cxx38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/CurveEditor.cxx b/src/CurveEditor.cxx
index edc3a46..699261d 100644
--- a/src/CurveEditor.cxx
+++ b/src/CurveEditor.cxx
@@ -5,15 +5,49 @@
// of the GNU General Public License, incorporated herein by reference.
#include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
#include <FL/Fl.H>
+#include <FL/fl_draw.H>
#include "CurveEditor.H"
-
CurveEditor::CurveEditor(int my_x, int my_y, int my_w, int my_h) :
Fl_Widget(my_x, my_y, my_w, my_h) {
+ n = 3;
+ X = (double*) calloc(n, sizeof(double));
+ Y = (double*) calloc(n, sizeof(double));
+
+ X[0] = 0.0;
+ Y[0] = 0.0;
+
+ X[1] = 0.2;
+ Y[1] = 0.4;
+
+ X[2] = 0.8;
+ Y[2] = 0.6;
+
+ acc = gsl_interp_accel_alloc ();
+ spline = gsl_spline_alloc (gsl_interp_cspline, n);
+ gsl_spline_init (spline, X, Y, n);
}
+void
+CurveEditor::draw() {
+ fl_color(FL_BLACK);
+ fl_rectf(x(), y(), w(), h());
+
+ fl_color(FL_WHITE);
+ fl_begin_line();
+ for (double _x = 0.0; _x < 1.0; _x = _x + 0.01) {
+ double _y = gsl_spline_eval(spline, _x, acc);
+
+ fl_vertex(x() + _x * w(), y() + h() * _y);
+ }
+ fl_end_line();
+
+ for (int i = 0; i < n; i++) {
+ fl_rect(x() + w() * X[i] - 2, y() + h() * Y[i] - 2, 4, 4);
+ }
+}