summaryrefslogtreecommitdiff
path: root/src/CurveEditor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/CurveEditor.cxx')
-rw-r--r--src/CurveEditor.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/CurveEditor.cxx b/src/CurveEditor.cxx
index ad73758..8ff8671 100644
--- a/src/CurveEditor.cxx
+++ b/src/CurveEditor.cxx
@@ -43,7 +43,7 @@ CurveEditor::draw() {
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_vertex(x() + _x * w(), y() + h() - h() * _y);
}
fl_end_line();
@@ -53,7 +53,7 @@ CurveEditor::draw() {
} else {
fl_color(FL_WHITE);
}
- fl_rect(x() + w() * X[i] - 2, y() + h() * Y[i] - 2, 4, 4);
+ fl_rect(x() + w() * X[i] - 2, y() + h() - h() * Y[i] - 2, 4, 4);
}
}
@@ -69,7 +69,7 @@ CurveEditor::handle(int event) {
if (Fl::event_button() == 1) {
for (int i = 0; i < n; i++) {
int x_i = (int) rint(X[i] * w());
- int y_i = (int) rint(Y[i] * h());
+ int y_i = (int) rint(h() - Y[i] * h());
if (mark_x >= x_i - 2 && mark_x <= x_i + 2 &&
mark_y >= y_i - 2 && mark_y <= y_i + 2) {
@@ -83,7 +83,7 @@ CurveEditor::handle(int event) {
return 1;
break;
case FL_DRAG:
- set(marked_point, (double) mark_x / w(), (double) mark_y / h());
+ set(marked_point, (double) mark_x / w(), 1.0 - (double) mark_y / h());
return 1;
break;
@@ -113,5 +113,11 @@ CurveEditor::set(int i, double _x, double _y) {
X[i] = _x;
Y[i] = _y;
gsl_spline_init (spline, X, Y, n);
+
+ printf("%4f,%4f", X[0], Y[0]);
+ for (int i = 1; i < n; i++) {
+ printf(";%4f,%4f", X[i], Y[i]);
+ }
+ printf("\n");
redraw();
}